diff --git a/apps/summon-safe/src/components/Toggle.tsx b/apps/summon-safe/src/components/Toggle.tsx index 4507b1c0..3efd882b 100644 --- a/apps/summon-safe/src/components/Toggle.tsx +++ b/apps/summon-safe/src/components/Toggle.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import styled from 'styled-components'; import { Control, Controller } from 'react-hook-form'; import { Switch, Text } from '@gnosis.pm/safe-react-components'; @@ -8,11 +9,18 @@ interface ToggleProps { required?: boolean; disabled?: boolean; shouldUnregister: boolean; + switchLabel?: string; control: Control; } +const Container = styled.div` + display: flex; + flex-direction: row; + align-items: center; +`; + const Toggle: React.FC = (props: ToggleProps) => { - const { id, label, required, control, shouldUnregister } = props; + const { id, label, required, control, shouldUnregister, switchLabel } = props; return ( = (props: ToggleProps) => { render={({ field }) => ( <> {`${label}${required ? ' (*)' : ''}`} - + + + {switchLabel && ( + {`${ + field.value === false ? 'Not ' : '' + }${switchLabel}`} + )} + )} /> diff --git a/apps/summon-safe/src/views/SummonForm.tsx b/apps/summon-safe/src/views/SummonForm.tsx index 0b05f416..66a96d5d 100644 --- a/apps/summon-safe/src/views/SummonForm.tsx +++ b/apps/summon-safe/src/views/SummonForm.tsx @@ -260,6 +260,7 @@ const SummonForm: React.FC = (props: SummonFormProps) => { required control={methods.control} shouldUnregister={false} + switchLabel="Transferrable" /> @@ -269,6 +270,7 @@ const SummonForm: React.FC = (props: SummonFormProps) => { required control={methods.control} shouldUnregister={false} + switchLabel="Transferrable" /> @@ -382,27 +384,27 @@ const SummonForm: React.FC = (props: SummonFormProps) => { - Starting Shamans + Starting Members - Shamans are powerful and have control over key components of the - DAO. Use caution in the spirit world. + You must have at least one member to summon. Add other summoning + members as desired. Members can be added later through a proposal. = (props: SummonFormProps) => { - Starting Members + Starting Shamans - You must have at least one member to summon. Add other summoning - members as desired. Members can be added later through a proposal. + Shamans are powerful and have control over key components of the + DAO. Use caution in the spirit world. ( - `${url}/safes/${getAddress(safeAddress)}/balances/` + `${url}/safes/${getAddress(safeAddress)}/balances/?exclude_spam=true` ); return { data: transformTokenBalances(res, safeAddress) }; diff --git a/libs/moloch-v3-fields/package.json b/libs/moloch-v3-fields/package.json index 072f5c5b..50489b8f 100644 --- a/libs/moloch-v3-fields/package.json +++ b/libs/moloch-v3-fields/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/moloch-v3-fields", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/moloch-v3-hooks/package.json b/libs/moloch-v3-hooks/package.json index 1a6b7063..55ae8f98 100644 --- a/libs/moloch-v3-hooks/package.json +++ b/libs/moloch-v3-hooks/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/moloch-v3-hooks", - "version": "0.5.3", + "version": "0.5.4", "peerDependencies": { "react-query": "^3.39.3" }, diff --git a/libs/moloch-v3-legos/package.json b/libs/moloch-v3-legos/package.json index 8690365a..b05ed2dc 100644 --- a/libs/moloch-v3-legos/package.json +++ b/libs/moloch-v3-legos/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/moloch-v3-legos", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", diff --git a/libs/moloch-v3-macro-ui/package.json b/libs/moloch-v3-macro-ui/package.json index 0bc292b4..9fa778b2 100644 --- a/libs/moloch-v3-macro-ui/package.json +++ b/libs/moloch-v3-macro-ui/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/moloch-v3-macro-ui", - "version": "0.5.3", + "version": "0.5.4", "peerDependencies": { "react-router-dom": "^6.4.3" }, diff --git a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeBalancesTable.tsx b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeBalancesTable.tsx new file mode 100644 index 00000000..245de312 --- /dev/null +++ b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeBalancesTable.tsx @@ -0,0 +1,71 @@ +import { useMemo } from 'react'; +import { Column, Row } from 'react-table'; + +import { DaoTable } from '../DaohausTable'; +import { Avatar } from '@daohaus/ui'; +import { SafeToken } from './SafeCard.styles'; + +type TokenBalanceType = { + tokenLogo?: string | null; + tokenName: string; + tokenSymbol: string; + balance: number; +}; + +type SafeBalancesTableProps = { + balances: Array; +}; + +export const SafeBalancesTable = ({ balances }: SafeBalancesTableProps) => { + const columns = useMemo[]>( + () => [ + { + Header: 'Asset', + accessor: 'tokenName', + Cell: ({ + value, + row, + }: { + value: string; + row: Row; + }) => { + return ( + +
+ +
+ {value} +
+ ); + }, + }, + { + Header: 'Balance', + accessor: 'balance', + Cell: ({ + value, + row, + }: { + value: number; + row: Row; + }) => { + return
{`${value} ${row.original.tokenSymbol}`}
; + }, + }, + ], + [balances] + ); + + return ( + + tableData={balances} + columns={columns} + sortableColumns={[]} + /> + ); +}; diff --git a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.styles.ts b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.styles.ts index b128fff3..807b5b79 100644 --- a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.styles.ts +++ b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.styles.ts @@ -69,3 +69,9 @@ export const SafeActionMenuLink = styled(RouterLink)` ${DropdownLinkStyles} font-weight: ${font.weight.bold}; `; + +export const SafeToken = styled.div` + display: flex; + align-items: center; + gap: 1rem; +`; diff --git a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx index 97d1b964..cf2dd61e 100644 --- a/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx +++ b/libs/moloch-v3-macro-ui/src/components/SafeCard/SafeCard.tsx @@ -1,25 +1,29 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; +import { Keychain, getNetwork } from '@daohaus/keychain-utils'; import { DaoSafe, MolochV3Dao } from '@daohaus/moloch-v3-data'; import { AddressDisplay, + Avatar, Bold, + CollapsibleCard, DataIndicator, H4, Link, ParXs, Tag, } from '@daohaus/ui'; -import { generateGnosisUiLink } from '@daohaus/utils'; -import { Keychain } from '@daohaus/keychain-utils'; +import { generateGnosisUiLink, toWholeUnits, truncValue } from '@daohaus/utils'; + import { DataGrid } from '../Layout'; +import { SafeActionMenu } from './SafeActionMenu'; +import { SafeBalancesTable } from './SafeBalancesTable'; import { SafeCardHeader, SafeContainer, SafeOverviewCard, TagSection, } from './SafeCard.styles'; -import { SafeActionMenu } from './SafeActionMenu'; type SafeCardProps = { dao: MolochV3Dao; @@ -38,6 +42,26 @@ export const SafeCard = ({ return safe.safeAddress === dao.safeAddress; }, [safe, dao]); + const nativeTokenSymbol = useMemo(() => { + const network = getNetwork(daoChain); + return network?.symbol || 'UNK'; + }, [daoChain]); + + const tokenBalances = useMemo(() => { + const network = getNetwork(daoChain); + return safe.tokenBalances.map((t) => { + return { + tokenLogo: t.token?.logoUri, + tokenName: t.token?.name || nativeTokenSymbol, + tokenSymbol: t.token?.symbol || nativeTokenSymbol, + balance: truncValue( + toWholeUnits(t.balance, t.token?.decimals || network?.tokenDecimals), + 4 + ), + }; + }); + }, [safe]); + return ( @@ -80,6 +104,24 @@ export const SafeCard = ({ + {safe.tokenBalances.length > 0 && ( + } + > +
+ {safe.tokenBalances.map((token) => ( + + ))} +
+
+ )}
); diff --git a/libs/profile-data/package.json b/libs/profile-data/package.json index 272904ef..cbe6ec32 100644 --- a/libs/profile-data/package.json +++ b/libs/profile-data/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/profile-data", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", diff --git a/libs/tx-builder/package.json b/libs/tx-builder/package.json index 1967ebec..63497e28 100644 --- a/libs/tx-builder/package.json +++ b/libs/tx-builder/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/tx-builder", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/ui/package.json b/libs/ui/package.json index b2cf3642..4c90aea4 100644 --- a/libs/ui/package.json +++ b/libs/ui/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/ui", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/utils/package.json b/libs/utils/package.json index cfdc27a9..ddca0fb9 100644 --- a/libs/utils/package.json +++ b/libs/utils/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/utils", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/wizard-form-builder/package.json b/libs/wizard-form-builder/package.json index 24c9c190..72e0a7ee 100644 --- a/libs/wizard-form-builder/package.json +++ b/libs/wizard-form-builder/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/wizard-form-builder", - "version": "0.2.3", + "version": "0.2.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo"