From b2696d2ddcce5e4dbfde2d68b0a2fe05269d7f97 Mon Sep 17 00:00:00 2001 From: Santiago Gonzalez Date: Tue, 22 Oct 2024 00:01:56 -0500 Subject: [PATCH 1/4] add minor UI fixes on summon-safe-app --- apps/summon-safe/src/components/Toggle.tsx | 19 +++++++- apps/summon-safe/src/views/SummonForm.tsx | 50 +++++++++++----------- 2 files changed, 43 insertions(+), 26 deletions(-) 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. Date: Tue, 22 Oct 2024 23:46:04 -0500 Subject: [PATCH 2/4] add safe token balances --- libs/moloch-v3-data/src/vaults.ts | 4 +- .../components/SafeCard/SafeBalancesTable.tsx | 71 +++++++++++++++++++ .../components/SafeCard/SafeCard.styles.ts | 6 ++ .../src/components/SafeCard/SafeCard.tsx | 50 +++++++++++-- 4 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 libs/moloch-v3-macro-ui/src/components/SafeCard/SafeBalancesTable.tsx diff --git a/libs/moloch-v3-data/src/vaults.ts b/libs/moloch-v3-data/src/vaults.ts index bcbb6cb6..2fa197e5 100644 --- a/libs/moloch-v3-data/src/vaults.ts +++ b/libs/moloch-v3-data/src/vaults.ts @@ -25,7 +25,9 @@ export const listTokenBalances = async ({ try { const res = await fetch.get( - `${url}/safes/${getAddress(safeAddress)}/balances/` + `${url}/safes/${getAddress( + safeAddress + )}/balances/?trusted=true&exclude_spam=true` ); return { data: transformTokenBalances(res, safeAddress) }; 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) => ( + + ))} +
+
+ )}
); From 25e255356b0b7e763ab2f5a9cc9b9aca8f4a59f6 Mon Sep 17 00:00:00 2001 From: Santiago Gonzalez Date: Tue, 22 Oct 2024 23:56:06 -0500 Subject: [PATCH 3/4] filter spam tokens only in safes --- libs/moloch-v3-data/src/vaults.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/moloch-v3-data/src/vaults.ts b/libs/moloch-v3-data/src/vaults.ts index 2fa197e5..c2145dc5 100644 --- a/libs/moloch-v3-data/src/vaults.ts +++ b/libs/moloch-v3-data/src/vaults.ts @@ -25,9 +25,7 @@ export const listTokenBalances = async ({ try { const res = await fetch.get( - `${url}/safes/${getAddress( - safeAddress - )}/balances/?trusted=true&exclude_spam=true` + `${url}/safes/${getAddress(safeAddress)}/balances/?exclude_spam=true` ); return { data: transformTokenBalances(res, safeAddress) }; From 61bb433f9be754599201864ac6269f7278af635d Mon Sep 17 00:00:00 2001 From: skuhlmann Date: Tue, 29 Oct 2024 14:28:39 -0600 Subject: [PATCH 4/4] v 0.5.4 --- libs/abis/package.json | 2 +- libs/connect-context/package.json | 2 +- libs/connect/package.json | 2 +- libs/contract-utils/package.json | 2 +- libs/data-fetch-utils/package.json | 2 +- libs/form-builder-base/package.json | 2 +- libs/form-builder/package.json | 2 +- libs/keychain-utils/package.json | 2 +- libs/moloch-v3-data/package.json | 2 +- libs/moloch-v3-fields/package.json | 2 +- libs/moloch-v3-hooks/package.json | 2 +- libs/moloch-v3-legos/package.json | 2 +- libs/moloch-v3-macro-ui/package.json | 2 +- libs/profile-data/package.json | 2 +- libs/tx-builder/package.json | 2 +- libs/ui/package.json | 2 +- libs/utils/package.json | 2 +- libs/wizard-form-builder/package.json | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libs/abis/package.json b/libs/abis/package.json index 5c870f3d..89781631 100644 --- a/libs/abis/package.json +++ b/libs/abis/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/abis", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", diff --git a/libs/connect-context/package.json b/libs/connect-context/package.json index 18d7a58a..d77adf44 100644 --- a/libs/connect-context/package.json +++ b/libs/connect-context/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/connect-context", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/connect/package.json b/libs/connect/package.json index 5c997405..e5164764 100644 --- a/libs/connect/package.json +++ b/libs/connect/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/connect", - "version": "0.5.3", + "version": "0.5.4", "peerDependencies": { "react-router-dom": "^6.4.3" }, diff --git a/libs/contract-utils/package.json b/libs/contract-utils/package.json index 0c5c3c4e..76f0a7fb 100644 --- a/libs/contract-utils/package.json +++ b/libs/contract-utils/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/contract-utils", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", diff --git a/libs/data-fetch-utils/package.json b/libs/data-fetch-utils/package.json index 1a3b3b32..f7594a0f 100644 --- a/libs/data-fetch-utils/package.json +++ b/libs/data-fetch-utils/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/data-fetch-utils", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", diff --git a/libs/form-builder-base/package.json b/libs/form-builder-base/package.json index a60a6425..6a7d30a9 100644 --- a/libs/form-builder-base/package.json +++ b/libs/form-builder-base/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/form-builder-base", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/form-builder/package.json b/libs/form-builder/package.json index d4d4bd03..1af4e28b 100644 --- a/libs/form-builder/package.json +++ b/libs/form-builder/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/form-builder", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/keychain-utils/package.json b/libs/keychain-utils/package.json index a6d61eb5..807becb2 100644 --- a/libs/keychain-utils/package.json +++ b/libs/keychain-utils/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/keychain-utils", - "version": "0.5.3", + "version": "0.5.4", "repository": { "type": "git", "url": "https://github.com/HausDAO/monorepo" diff --git a/libs/moloch-v3-data/package.json b/libs/moloch-v3-data/package.json index 40d83596..b023251c 100644 --- a/libs/moloch-v3-data/package.json +++ b/libs/moloch-v3-data/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/moloch-v3-data", - "version": "0.5.3", + "version": "0.5.4", "type": "commonjs", "repository": { "type": "git", 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/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"