Skip to content

Commit

Permalink
feat: add voluntary contribution component (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov authored Sep 18, 2024
1 parent 8c59d31 commit d0453a7
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 154 deletions.
2 changes: 1 addition & 1 deletion packages/wallet-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@lifi/sdk": "^3.2.3",
"@solana/wallet-adapter-base": "^0.9.23",
"react": "^18.3.1",
"viem": "^2.21.8",
"viem": "^2.21.9",
"wagmi": "^2.12.12"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/widget-playground-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"core-js": "^3.38.1",
"lodash.isequal": "^4.5.0",
"microdiff": "^1.4.0",
"next": "14.2.11",
"next": "14.2.12",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"viem": "^2.21.8",
"viem": "^2.21.9",
"wagmi": "^2.12.12",
"zustand": "^4.5.5"
},
Expand All @@ -43,7 +43,7 @@
"@types/react": "^18.3.7",
"@types/react-dom": "^18.3.0",
"eslint": "^8.57.1",
"eslint-config-next": "14.2.11",
"eslint-config-next": "14.2.12",
"typescript": "^5.6.2"
},
"private": true
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-playground-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
"viem": "^2.21.8",
"viem": "^2.21.9",
"wagmi": "^2.12.12",
"zustand": "^4.5.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"react-intersection-observer": "^9.13.1",
"react-router-dom": "^6.26.2",
"uuid": "^10.0.0",
"viem": "^2.21.8",
"viem": "^2.21.9",
"wagmi": "^2.12.12",
"zustand": "^4.5.5"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/widget/src/components/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
parseFloat(feeCollectionStep.action.fromToken.priceUSD);
}

const showIntegratorFeeCollectionDetails =
feeAmountUSD || Number.isFinite(feeConfig?.fee);

return (
<Card selectionColor="secondary" {...props}>
<Box display="flex" alignItems="center" px={2} py={1.75}>
Expand Down Expand Up @@ -138,7 +141,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
</FeeBreakdownTooltip>
</Box>
) : null}
{feeAmountUSD ? (
{showIntegratorFeeCollectionDetails ? (
<Box display="flex" justifyContent="space-between" mb={0.5}>
<Typography variant="body2">
{feeConfig?.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const StatusBottomSheetContent: React.FC<
subvariantOptions,
contractSecondaryComponent,
contractCompactComponent,
feeConfig,
} = useWidgetConfig();
const { getChainById } = useAvailableChains();

Expand Down Expand Up @@ -251,6 +252,9 @@ export const StatusBottomSheetContent: React.FC<
hasEnumFlag(status, RouteExecutionStatus.Done) &&
(contractCompactComponent || contractSecondaryComponent);

const VcComponent =
status === RouteExecutionStatus.Done ? feeConfig?._vcComponent : undefined;

return (
<Box p={3} ref={ref}>
{!showContractComponent ? (
Expand Down Expand Up @@ -296,6 +300,7 @@ export const StatusBottomSheetContent: React.FC<
{secondaryMessage ? (
<Typography py={1}>{secondaryMessage}</Typography>
) : null}
{VcComponent ? <VcComponent route={route} /> : null}
<Box mt={2}>
<Button variant="contained" fullWidth onClick={handlePrimaryButton}>
{status === RouteExecutionStatus.Idle ? t('button.ok') : null}
Expand Down
6 changes: 6 additions & 0 deletions packages/widget/src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
ChainType,
ContractCall,
Order,
RouteExtended,
RouteOptions,
SDKConfig,
StaticToken,
Expand All @@ -23,6 +24,7 @@ import type {
} from '@wagmi/connectors';
import type {
CSSProperties,
FC,
MutableRefObject,
ReactNode,
RefObject,
Expand Down Expand Up @@ -149,6 +151,10 @@ export interface WidgetFeeConfig {
* @returns A promise that resolves to the calculated fee as a number (e.g., 0.03 represents a 3% fee)
*/
calculateFee?(params: CalculateFeeParams): Promise<number | undefined>;
/**
* @internal
*/
_vcComponent: FC<{ route: RouteExtended }>;
}

export interface ToAddress {
Expand Down
Loading

0 comments on commit d0453a7

Please sign in to comment.