Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,196 changes: 4,595 additions & 4,601 deletions dist/cspr-design.es.js

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions dist/cspr-design.umd.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions dist/lib/components/deploy-actions/deploy-result-row.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { default as React } from 'react';
import { ActionIdentificationHashesType } from './deploy-action-row';
import { AccountInfoResult, ContractResult, DataResponse, Deploy, DeployContractPackageResult, GetDeployResult } from '../../types/types';
import { DataResponse, Deploy, GetDeployResult, ContractResult, DeployContractPackageResult, AccountInfoResult } from '../../types/types';
export declare enum ResultRowVariation {
default = "default",
gray = "gray"
Expand All @@ -9,9 +9,7 @@ export interface DeployResultRowComponentProps {
deploy: Deploy;
loading: boolean;
actionIdentificationHashes: ActionIdentificationHashesType;
deployRawData?: DataResponse<GetDeployResult & {
api_version: string;
}> | null;
deployRawData?: DataResponse<GetDeployResult> | null;
actionComponents?: React.ReactElement[] | null;
variation?: ResultRowVariation;
shouldCollapse?: boolean;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/lib/utils/named-key.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export interface SplitDataType {
prefix: string;
hash: string;
}
export declare const prefixOnlyRegExp: RegExp;
export declare const deriveSplitDataFromNamedKeyValue: (namedKeyValue: string) => SplitDataType;
//# sourceMappingURL=named-key.d.ts.map
2 changes: 1 addition & 1 deletion dist/lib/utils/named-key.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions src/lib/components/deploy-actions/deploy-result-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import TransferActionRow from './components/TransferActionRow';
import { ActionIdentificationHashesType } from './deploy-action-row';
import { DeployActionDataProvider } from './services/deploy-action-context';
import {
AccountInfoResult,
ContractResult,
ContractTypeId,
DataResponse,
Deploy, DeployContractPackageResult,
Deploy,
DeployTransferResult,
FTActionsResult,
GetDeployResult,
NftActionsResult,
GetDeployResult, ContractResult, DeployContractPackageResult, AccountInfoResult,
} from '../../types/types';
import FlexRow from '../flex-row/flex-row';
import BodyText from '../body-text/body-text';
import FlexColumn from '../flex-column/flex-column';
import ExpandCollapsedButton from '../expand-collapsed/expand-collapsed-button';
import { getDeployStatus, Status } from '../deploy-status/deploy-status';
import {isTransferDeploy} from "./utils/contract";
import {isNonNullable} from "../../utils/guards";
import {NftTypeToEntryPointMap} from '../../types/NFTToken';
import {FTTransactionResult, FTActionType} from '../../types/FTToken';
import BodyText from "../body-text/body-text.tsx";


const DefaultResultItem = styled(FlexRow)(({ theme }) => ({
padding: '14px 0',
Expand Down Expand Up @@ -60,9 +59,9 @@ const GrayResultItem = styled(FlexRow)(({ theme }) => ({

const ResultItemWrapper = ({ variation, ...props }) => {
return variation === ResultRowVariation.default ? (
<DefaultResultItem {...props} />
<DefaultResultItem {...props} />
) : (
<GrayResultItem {...props} />
<GrayResultItem {...props} />
);
};

Expand All @@ -85,7 +84,7 @@ export interface DeployResultRowComponentProps {
deploy: Deploy;
loading: boolean;
actionIdentificationHashes: ActionIdentificationHashesType;
deployRawData?: DataResponse< GetDeployResult & {api_version: string}> | null;
deployRawData?: DataResponse<GetDeployResult> | null;
actionComponents?: React.ReactElement[] | null;
variation?: ResultRowVariation;
shouldCollapse?: boolean;
Expand Down Expand Up @@ -175,12 +174,11 @@ const getSortedResultComponents = ({
getActionElementToRender(action)
);

const combinedActionComponents = [
return [
associatedKeyComponent,
...sortedActionComponents,
...(actionComponents || []),
].filter(isNonNullable);
return combinedActionComponents;
};

const manageCollapsingResults = ({
Expand Down Expand Up @@ -254,6 +252,8 @@ export const DeployResultRowComponent = (
actionComponents,
actionIdentificationHashes,
});
const actionsCount = combinedActionComponents?.length ?? 0;
const isSingleResult = actionsCount <= 1;

const [isCollapsed, setCollapsed] = useState<boolean>(shouldCollapse);

Expand All @@ -278,7 +278,7 @@ export const DeployResultRowComponent = (

const collapsedLabel =
combinedActionComponents?.length <= 1 ? `View ${combinedActionComponents?.length} result`
: `View all ${combinedActionComponents?.length} results`;
: `View all ${combinedActionComponents?.length} results`;
const expandedLabel =
combinedActionComponents?.length <= 1
? 'Collapse result'
Expand Down Expand Up @@ -314,7 +314,7 @@ export const DeployResultRowComponent = (
type DeployResultRowProps = DeployResultRowComponentProps & {
getAccountInfo: (publicKey: string) => AccountInfoResult | null | undefined;
getContractPackageInfoByHash?: (
contractPackageHash: string,
contractPackageHash: string,
) => DeployContractPackageResult | null | undefined;
getContractInfoByHash?: (
contractHash: string,
Expand Down Expand Up @@ -356,14 +356,14 @@ export const DeployResultRow = (props: DeployResultRowProps) => {
return null;
}
return (
<DeployActionDataProvider
getAccountInfo={getAccountInfo}
getContractPackageInfoByHash={getContractPackageInfoByHash}
getContractInfoByHash={getContractInfoByHash}
csprLiveDomainPath={csprLiveDomainPath}
>
<DeployResultRowComponent {...rest} />
</DeployActionDataProvider>
<DeployActionDataProvider
getAccountInfo={getAccountInfo}
getContractPackageInfoByHash={getContractPackageInfoByHash}
getContractInfoByHash={getContractInfoByHash}
csprLiveDomainPath={csprLiveDomainPath}
>
<DeployResultRowComponent {...rest} />
</DeployActionDataProvider>
);
};

Expand Down
62 changes: 30 additions & 32 deletions src/lib/components/named-key-value/named-key-value.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
import React from 'react';
import { formatHash, HashLength } from '../../utils/formatters';
import { deriveSplitDataFromNamedKeyValue } from '../../utils/named-key';
import { NamedKeyPrefix } from '../../utils/named-key-prefix';
import { useMatchMedia } from '../../utils/match-media';
import FlexRow from '../flex-row/flex-row';
import Link from '../link/link';

interface NamedKeyValueProps {
namedKey: string;
noPrefix?: boolean;
hashLength?: HashLength;
csprLiveDomainPath: string;
namedKey: string;
noPrefix?: boolean;
hashLength?: HashLength;
csprLiveDomainPath: string;
}

export const NamedKeyValue = ({
namedKey,
noPrefix,
hashLength,
csprLiveDomainPath,
export const NamedKeyValue = (
{
namedKey,
noPrefix,
hashLength,
csprLiveDomainPath,
}: NamedKeyValueProps) => {
const responsiveHashLength = useMatchMedia(
[HashLength.TINY, HashLength.MEDIUM, HashLength.FULL, HashLength.FULL],
[],
);
const { prefix, hash } = deriveSplitDataFromNamedKeyValue(namedKey);
const { prefix, hash } = deriveSplitDataFromNamedKeyValue(namedKey);

const isURefNamedKey = namedKey.includes(NamedKeyPrefix.UREF);
const redirectHash = isURefNamedKey ? namedKey : hash;
const responsiveHashLength = useMatchMedia(
[HashLength.TINY, HashLength.MEDIUM, HashLength.FULL, HashLength.FULL],
[hashLength],
);

const redirectPath = `${csprLiveDomainPath}/search/${redirectHash}`;
return (
<FlexRow>
{redirectPath ? (
<Link color={'hash'} href={redirectPath}>
{!noPrefix && prefix}
{formatHash(hash, hashLength || responsiveHashLength)}
</Link>
) : (
formatHash(hash, hashLength || responsiveHashLength)
)}
</FlexRow>
);
};
const resolvedHashLength = hashLength ?? responsiveHashLength;

const redirectPath = `${csprLiveDomainPath}/search/${namedKey}`;

export default NamedKeyValue;
const displayValue = formatHash(hash, resolvedHashLength);

return (
<FlexRow>
<Link color="hash" href={redirectPath}>
{!noPrefix && prefix}
{displayValue}
</Link>
</FlexRow>
);
};
export default NamedKeyValue;
24 changes: 10 additions & 14 deletions src/lib/utils/named-key.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { getNamedKeyPrefix, hashPrefixRegExpV2 } from './named-key-prefix';

export interface SplitDataType {
prefix: string;
hash: string;
}

export const prefixOnlyRegExp = new RegExp(`(?:(entity-)?contract(?:-package)?|account-hash|dictionary|withdraw|balance|deploy|uref|hash|era|bid)-(?=[0-9a-fA-F])`,
'gi'
);

export const deriveSplitDataFromNamedKeyValue = (
namedKeyValue: string,
namedKeyValue: string
): SplitDataType => {
const [hash, lastDigits] = namedKeyValue
.replace(hashPrefixRegExpV2, '')
.split('-');

const formattedPrefix = getNamedKeyPrefix(namedKeyValue);
const formattedHash = lastDigits ? `${hash}-${lastDigits}` : `${hash}`;
const match = namedKeyValue.match(prefixOnlyRegExp);
const prefix = match ? match[0] : '';
const hash = prefix ? namedKeyValue.slice(prefix.length) : namedKeyValue;

return {
prefix: formattedPrefix,
hash: formattedHash,
};
};
return { prefix, hash };
};
Loading