Skip to content

Commit

Permalink
Merge pull request #85 from TalismanSociety/fix/misc-errors
Browse files Browse the repository at this point in the history
fix: miscelanious errors
  • Loading branch information
UrbanWill authored Oct 16, 2024
2 parents 85324e2 + 1087c84 commit 3a9da44
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 104 deletions.
3 changes: 2 additions & 1 deletion apps/multisig/src/domains/auth/useMe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type MeOutput = {
}

const ME_QUERY = gql`
{
query MeQuery {
me {
error
user {
Expand All @@ -40,6 +40,7 @@ export const useMe = () => {
} = useQuery<MeOutput>(ME_QUERY, {
fetchPolicy: 'network-only',
notifyOnNetworkStatusChange: true,
skip: !selectedAccount,
})
const signOut = useSignOut()

Expand Down
5 changes: 4 additions & 1 deletion apps/multisig/src/domains/multisig/vaults-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export const vaultsOfAccount = selector({

// check if the multisig is on a supported chain
const chain = supportedChains.find(c => c.genesisHash === tx.extrinsic.block.chainGenesisHash)
if (!chain) throw new Error('Chain not supported')
if (!chain) {
console.warn('Chain not supported')
return
}

// a multisig transaction should have a threshold, except for as_multi_threshold_1
let threshold: number | undefined = tx.extrinsic.callArgs.threshold
Expand Down
23 changes: 13 additions & 10 deletions apps/multisig/src/domains/staking/ValidatorsWatcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ export const ValidatorsWatcher: React.FC = () => {
const [validators, setValidators] = useRecoilState(validatorsState)

const fetchIdentities = useCallback(async (addresses: string[], api: ApiPromise) => {
if (!api.query.identity.identityOf) return []
if (!api.query.identity?.identityOf) return []
try {
const identities = await api.query.identity.identityOf.multi(addresses)
const addressesWithIdentity: [string, string][] = []
identities.forEach(({ value: [registration] }, index) => {
const nameRaw = registration?.info?.display.toHuman() as { Raw: string }
let name = nameRaw?.Raw
const address = addresses[index]

name = u8aToString(u8aUnwrapBytes(name))

if (name && address) addressesWithIdentity.push([address, name])
identities.forEach((option, index) => {
if (option.isSome) {
const [registration] = option.value
const nameRaw = registration?.info?.display.toHuman() as { Raw: string }
const name = u8aToString(u8aUnwrapBytes(nameRaw?.Raw))
const address = addresses[index]

if (name && address) {
addressesWithIdentity.push([address, name])
}
}
})
return addressesWithIdentity
} catch (e) {
Expand All @@ -45,7 +48,7 @@ export const ValidatorsWatcher: React.FC = () => {

const fetchSupersIdentities = useCallback(
async (addresses: string[], api: ApiPromise) => {
if (!api.query.identity.superOf) return []
if (!api.query.identity?.superOf) return []

const addressesWithIdentity: [string, { name: string; subName: string }][] = []
const addressesWithSubIdentity: [string, { subIdentity: string; superAddress: string }][] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,13 @@ const AddressBookTable = ({
<div className="grid gap-[8px]">
{/* Column Headers */}
<div className="grid grid-cols-[1fr_2fr_1fr_1fr] gap-4 font-semibold px-4">
{table
.getHeaderGroups()
.map(headerGroup =>
headerGroup.headers.map(header => (
<div className="p-2 text-left last:text-right last:pr-[50px] text-[14px]">
{flexRender(header.column.columnDef.header, header.getContext())}
</div>
))
)}
{table.getHeaderGroups().map(headerGroup =>
headerGroup.headers.map(header => (
<div className="p-2 text-left last:text-right last:pr-[50px] text-[14px]" key={header.id}>
{flexRender(header.column.columnDef.header, header.getContext())}
</div>
))
)}
</div>

{/* Rows */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const AddressInputCell: React.FC<Props> = ({
>
{filteredContacts?.map(contact => (
<div
key={contact.address.toSs58()}
className="w-full p-[12px] hover:bg-gray-700 cursor-pointer"
onClick={() => onChangeAddress(contact.address)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { cn } from '@util/tailwindcss'
import { isExtrinsicProxyWrapped } from '@util/extrinsics'
import { CONFIG } from '@lib/config'
import { VestingDateRange } from '@components/VestingDateRange'
import { Table, TableCell, TableHead, TableHeader, TableRow } from '@components/ui/table'
import { Table, TableCell, TableHead, TableHeader, TableRow, TableBody } from '@components/ui/table'
import { CircularProgressIndicator } from '@talismn/ui'

const CopyPasteBox: React.FC<{ content: string; label?: string }> = ({ content, label }) => {
Expand Down Expand Up @@ -175,93 +175,62 @@ const MultiSendExpandedDetails = ({ t }: { t: Transaction }) => {
</TableRow>
</TableHeader>

{t.decoded?.recipients.map(({ address, balance, vestingSchedule }, i) => (
<TableRow key={i} className="last:border-b-0 h-[55px]">
<TableCell>
<AccountDetails
name={contactByAddress[address.toSs58()]?.name}
address={address}
chain={t.multisig.chain}
breakLine
withAddressTooltip
identiconSize={28}
disableCopy
hideIdenticon
isNameLoading={isLoading}
/>
</TableCell>
{shouldDisplayCategory && (
<TableCell className="text-right ml-auto">
{isLoading ? (
<div className="flex justify-end">
<CircularProgressIndicator size={16} />
</div>
) : (
contactByAddress[address.toSs58()]?.category?.name
)}
<TableBody>
{t.decoded?.recipients.map(({ address, balance, vestingSchedule }, i) => (
<TableRow key={i} className="last:border-b-0 h-[55px]">
<TableCell>
<AccountDetails
name={contactByAddress[address.toSs58()]?.name}
address={address}
chain={t.multisig.chain}
breakLine
withAddressTooltip
identiconSize={28}
disableCopy
hideIdenticon
isNameLoading={isLoading}
/>
</TableCell>
)}
{shouldDisplaySubcategory && (
<TableCell className="text-right">
{isLoading ? (
<div className="flex justify-end">
<CircularProgressIndicator size={16} />
{shouldDisplayCategory && (
<TableCell className="text-right ml-auto">
{isLoading ? (
<div className="flex justify-end">
<CircularProgressIndicator size={16} />
</div>
) : (
contactByAddress[address.toSs58()]?.category?.name
)}
</TableCell>
)}
{shouldDisplaySubcategory && (
<TableCell className="text-right">
{isLoading ? (
<div className="flex justify-end">
<CircularProgressIndicator size={16} />
</div>
) : (
contactByAddress[address.toSs58()]?.sub_category?.name
)}
</TableCell>
)}
{vestingSchedule && (
<TableCell>
<div className="[&>p>span]:block [&>p]:whitespace-nowrap">
<VestingDateRange
chainGenesisHash={t.multisig.chain.genesisHash}
vestingSchedule={vestingSchedule}
/>
</div>
) : (
contactByAddress[address.toSs58()]?.sub_category?.name
)}
</TableCell>
)}
{vestingSchedule && (
</TableCell>
)}
<TableCell>
<div className="[&>p>span]:block [&>p]:whitespace-nowrap">
<VestingDateRange chainGenesisHash={t.multisig.chain.genesisHash} vestingSchedule={vestingSchedule} />
<div className="flex flex-col items-end">
<AmountRow balance={balance} hideIcon hideSymbol fontSize={14} />
</div>
</TableCell>
)}
<TableCell>
<div className="flex flex-col items-end">
<AmountRow balance={balance} hideIcon hideSymbol fontSize={14} />
</div>
</TableCell>
</TableRow>

// <div
// key={`${address.toSs58(t.multisig.chain)}-${JSON.stringify(balance.amount)}`}
// className="grid gap-[16px] border-b border-gray-500 py-[8px] last:border-b-0 last:pb-0"
// >
// <div className="flex items-center gap-[8px]">
// <div className="w-full flex flex-col">
// <div className="flex items-center justify-between">
// <div className="[&>div>div]:gap-0">
// <AccountDetails
// name={contactByAddress[address.toSs58()]?.name}
// address={address}
// chain={t.multisig.chain}
// breakLine
// withAddressTooltip
// identiconSize={28}
// disableCopy
// />
// </div>
// <div className="text-right flex flex-col items-end">
// <AmountRow balance={balance} />
// </div>
// </div>
// {vestingSchedule ? (
// <div className="w-full flex items-center justify-between pl-[36px]">
// <p className="text-[14px] text-offWhite">Vesting Period</p>
// <VestingDateRange
// className="text-center"
// chainGenesisHash={t.multisig.chain.genesisHash}
// vestingSchedule={vestingSchedule}
// />
// </div>
// ) : null}
// </div>
// </div>
// </div>
))}
</TableRow>
))}
</TableBody>
</Table>
</div>
)
Expand Down

0 comments on commit 3a9da44

Please sign in to comment.