-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chalabi/safe truncation #204
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import { ThresholdDecisionPolicy } from '@liftedinit/manifestjs/dist/codegen/cosmos/group/v1/types'; | ||
import { Duration } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/duration'; | ||
import { secondsToHumanReadable } from '@/utils/string'; | ||
|
||
import env from '@/config/env'; | ||
export default function ConfirmationForm({ | ||
nextStep, | ||
prevStep, | ||
|
@@ -28,10 +28,15 @@ | |
}; | ||
|
||
// Convert the object to a JSON string | ||
const jsonString = JSON.stringify(groupMetadata); | ||
|
||
const { tx, isSigning, setIsSigning } = useTx('manifest'); | ||
const { estimateFee } = useFeeEstimation('manifest'); | ||
let jsonString: string; | ||
try { | ||
jsonString = JSON.stringify(groupMetadata); | ||
} catch (error) { | ||
console.error('Failed to serialize group metadata:', error); | ||
throw new Error('Invalid group metadata format'); | ||
} | ||
Comment on lines
+31
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add test coverage for JSON serialization error handling The test file lacks coverage for the JSON serialization error handling. Consider adding these test cases:
🔗 Analysis chainAdd test coverage for error handling. The error handling for JSON serialization is good, but it lacks test coverage. Could you add test cases to cover the error handling scenario? Here's a verification script to check current test coverage: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check test coverage for the error handling block
rg -l "test.*ConfirmationForm.*metadata.*serialization" -t ts
Length of output: 63 Script: #!/bin/bash
# Find test files related to ConfirmationForm
fd "ConfirmationForm.*test" --type f
# If no direct test file found, check for test files in the same directory
fd ".*test.*\.(ts|tsx)$" --type f --exec grep -l "ConfirmationForm"
Length of output: 366 Script: #!/bin/bash
# Check content of the relevant test file
cat "components/groups/forms/groups/__tests__/ConfirmationForm.test.tsx"
Length of output: 2752 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 34-35: components/groups/forms/groups/ConfirmationForm.tsx#L34-L35 |
||
const { tx, isSigning, setIsSigning } = useTx(env.chain); | ||
const { estimateFee } = useFeeEstimation(env.chain); | ||
chalabi2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const minExecutionPeriod: Duration = { | ||
seconds: BigInt(0), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
import ProfileAvatar from '@/utils/identicon'; | ||
import { useBalance } from '@/hooks/useQueries'; | ||
import { CopyIcon } from '@/components/icons'; | ||
import { getRealLogo, shiftDigits, truncateString } from '@/utils'; | ||
import { getRealLogo, shiftDigits, truncateAddress } from '@/utils'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add basic test coverage for truncateAddress utility The
🔗 Analysis chainAdd test coverage for address truncation. The address truncation implementation looks good, but the static analysis indicates that line 86 lacks test coverage. Consider adding test cases to verify the truncation behavior. Would you like me to help generate test cases for the address truncation functionality? Also applies to: 86-86 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for existing tests of Connected component
fd -e tsx -e ts "Connected.test" components/react/views/
Length of output: 56 Script: #!/bin/bash
# Find all test files in views directory
echo "=== Test files in views ==="
fd -e test.tsx -e test.ts . components/react/views/
# Find truncateAddress tests
echo -e "\n=== truncateAddress tests ==="
fd -e test.tsx -e test.ts . utils/
# Find actual usage of truncateAddress
echo -e "\n=== truncateAddress usage in Connected ==="
rg -C 2 "truncateAddress" components/react/views/Connected.tsx
Length of output: 848 Script: #!/bin/bash
# Find truncateAddress tests using ripgrep
echo "=== Searching for truncateAddress tests ==="
rg -l "truncateAddress.*test"
# Find truncateAddress implementation
echo -e "\n=== truncateAddress implementation ==="
rg -C 4 "export.*truncateAddress"
Length of output: 628 |
||
import Image from 'next/image'; | ||
import { MdContacts } from 'react-icons/md'; | ||
import { Contacts } from './Contacts'; | ||
|
@@ -83,7 +83,7 @@ | |
<p className="text-lg font-semibold">{username || 'Anonymous'}</p> | ||
<div className="flex items-center"> | ||
<p className="text-sm text-gray-500 dark:text-gray-400"> | ||
{truncateString(address || '', 12)} | ||
{truncateAddress(address || '')} | ||
</p> | ||
<button | ||
onClick={copyAddress} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import { WalletStatus } from 'cosmos-kit'; | ||
import { MdWallet } from 'react-icons/md'; | ||
import env from '@/config/env'; | ||
import { truncateAddress, truncateString } from '@/utils'; | ||
|
||
const buttons = { | ||
Disconnected: { | ||
|
@@ -130,17 +131,11 @@ | |
className="font-medium text-xl text-center mb-2 truncate" | ||
title={username || 'Connected user'} | ||
> | ||
{username | ||
? username.length > 20 | ||
? `${username.slice(0, 20)}...` | ||
: username | ||
: 'Connected User'} | ||
{username ? truncateString(username, 20) : 'Connected User'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add comprehensive test coverage for wallet component and utilities The verification confirms that test coverage is missing for:
Please add test cases covering both the component behavior and the utility function, ensuring various scenarios like:
🔗 Analysis chainAdd test coverage for username truncation. The username truncation implementation lacks test coverage. Could you add test cases for the username truncation? Here's a verification script to check current test coverage: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check test coverage for username truncation
rg -l "test.*WalletSection.*username.*truncate" -t ts
Length of output: 55 Script: #!/bin/bash
# Find all test files related to wallet
echo "=== Wallet-related test files ==="
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts | rg -i "wallet"
# Find truncateString utility tests
echo -e "\n=== TruncateString utility tests ==="
rg -l "truncateString" -t ts | rg "test|spec"
# Find any username truncation tests
echo -e "\n=== Username truncation tests ==="
rg -l "username.*truncate|truncate.*username" -t ts
Length of output: 436 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 134-134: components/wallet.tsx#L134 |
||
</p> | ||
<div className="bg-base-100 dark:bg-base-200 rounded-full py-2 px-4 text-center mb-4 flex items-center flex-row justify-between w-full "> | ||
<p className="text-xs truncate flex-grow"> | ||
{address | ||
? `${address.slice(0, 12)}...${address.slice(-6)}` | ||
: 'Address not available'} | ||
{address ? truncateAddress(address) : 'Address not available'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add test coverage for address truncation utility The address truncation functionality requires test coverage at two levels:
Example test cases should cover:
🔗 Analysis chainAdd test coverage for address truncation. The address truncation implementation lacks test coverage. Could you add test cases for the address truncation? Here's a verification script to check current test coverage: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check test coverage for address truncation
rg -l "test.*WalletSection.*address.*truncate" -t ts
Length of output: 54 Script: #!/bin/bash
# Find truncateAddress function definition
ast-grep --pattern 'function truncateAddress($_) { $$$ }'
# Find all test files related to wallet
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts . | rg -i "wallet"
# Search for any tests containing "address" string
rg "test.*address" -t ts -t tsx
Length of output: 189 Script: #!/bin/bash
# Find all wallet-related files to understand structure
fd . -e ts -e tsx | rg -i "wallet"
# Try different patterns for truncateAddress
ast-grep --pattern 'const truncateAddress = $_'
ast-grep --pattern 'export const truncateAddress = $_'
ast-grep --pattern 'export function truncateAddress($_)'
# Search for address-related tests with correct extension
rg "test.*address" -t ts
Length of output: 2538 Script: #!/bin/bash
# Check for utility files and inline truncate implementation
rg "truncate.*address" -t ts -t tsx
# Look at the wallet component implementation
cat components/wallet.tsx
Length of output: 10539 Script: #!/bin/bash
# Check for utils tests
fd . -e test.ts -e test.tsx | rg "utils"
# Look at the utils implementation
cat utils/index.ts
Length of output: 400 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 138-138: components/wallet.tsx#L138 |
||
</p> | ||
<button | ||
onClick={() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Add test coverage for address truncation behavior
The existing test suite in
components/bank/components/__tests__/historyBox.test.tsx
lacks coverage for the address truncation functionality. Consider adding a test case that verifies addresses are correctly truncated to 24 characters.🔗 Analysis chain
LGTM! Consider adding test coverage.
The change to standardize address truncation to 24 characters aligns with the broader effort to ensure consistent address display across the application.
The line is flagged as not covered by tests. Consider adding test coverage to ensure the address truncation behavior works as expected:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 136
Script:
Length of output: 3679
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 251-251: components/bank/components/historyBox.tsx#L251
Added line #L251 was not covered by tests