Skip to content

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder committed Jan 16, 2024
1 parent a619197 commit 85e0497
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 322 deletions.
5 changes: 1 addition & 4 deletions api/src/routes/nova/block/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { ValidationHelper } from "../../../utils/validationHelper";
* @param request The request.
* @returns The response.
*/
export async function get(
_: IConfiguration,
request: IBlockRequest
): Promise<IBlockResponse> {
export async function get(_: IConfiguration, request: IBlockRequest): Promise<IBlockResponse> {
const networkService = ServiceFactory.get<NetworkService>("network");
const networks = networkService.networkNames();
ValidationHelper.oneOf(request.network, networks, "network");
Expand Down
5 changes: 1 addition & 4 deletions api/src/routes/nova/block/metadata/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { ValidationHelper } from "../../../../utils/validationHelper";
* @param request The request.
* @returns The response.
*/
export async function get(
_: IConfiguration,
request: IBlockRequest
): Promise<IBlockDetailsResponse> {
export async function get(_: IConfiguration, request: IBlockRequest): Promise<IBlockDetailsResponse> {
const networkService = ServiceFactory.get<NetworkService>("network");
const networks = networkService.networkNames();
ValidationHelper.oneOf(request.network, networks, "network");
Expand Down
23 changes: 7 additions & 16 deletions client/src/app/components/nova/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ const Input: React.FC<InputProps> = ({ input, network }) => {

const fallbackInputView = (
<React.Fragment>
<div
className="card--content__input"
onClick={() => setIsExpanded(!isExpanded)}
>
<div className="card--content__input" onClick={() => setIsExpanded(!isExpanded)}>
<div className={classNames("margin-r-t", "card--content__input--dropdown", { opened: isExpanded })}>
<DropdownIcon />
</div>
Expand All @@ -45,7 +42,7 @@ const Input: React.FC<InputProps> = ({ input, network }) => {
</div>
{input.amount && (
<span
onClick={e => {
onClick={(e) => {
setIsFormattedBalance(!isFormattedBalance);
e.stopPropagation();
}}
Expand All @@ -72,26 +69,20 @@ const Input: React.FC<InputProps> = ({ input, network }) => {
</div>
<div className="card--label"> Transaction Id</div>
<div className="card--value">
<Link to={`/${network}/transaction/${input.transactionId}`} className="margin-r-t" >
<Link to={`/${network}/transaction/${input.transactionId}`} className="margin-r-t">
{input.transactionId}
</Link>
</div>
<div className="card--label"> Transaction Output Index</div>
<div className="card--value">{input.transactionInputIndex}</div>
</React.Fragment>)}
</React.Fragment>
)}
</React.Fragment>
);

const outputId = Utils.computeOutputId(
input.transactionId, input.transactionInputIndex
);
const outputId = Utils.computeOutputId(input.transactionId, input.transactionInputIndex);

return input.output ?
<OutputView
outputId={outputId}
output={input.output.output}
showCopyAmount={true}
/> : fallbackInputView;
return input.output ? <OutputView outputId={outputId} output={input.output.output} showCopyAmount={true} /> : fallbackInputView;
};

export default Input;
102 changes: 51 additions & 51 deletions client/src/app/components/nova/Unlocks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { AccountUnlock, AnchorUnlock, EmptyUnlock, MultiUnlock, NftUnlock, ReferenceUnlock, SignatureUnlock, Unlock, UnlockType } from "@iota/sdk-wasm-nova/web";
import {
AccountUnlock,
AnchorUnlock,
EmptyUnlock,
MultiUnlock,
NftUnlock,
ReferenceUnlock,
SignatureUnlock,
Unlock,
UnlockType,
} from "@iota/sdk-wasm-nova/web";
import classNames from "classnames";
import React, { useState } from "react";
import DropdownIcon from "~assets/dropdown-arrow.svg?react";
Expand Down Expand Up @@ -39,75 +49,65 @@ const Unlocks: React.FC<IUnlocksProps> = ({ unlocks }) => {

return (
<div className="card--content__output unlocks">
<div
onClick={() => setIsExpanded(!isExpanded)}
className="card--value card-header--wrapper"
>
<div onClick={() => setIsExpanded(!isExpanded)} className="card--value card-header--wrapper">
<div className={classNames("card--content--dropdown", { opened: isExpanded })}>
<DropdownIcon />
</div>
<div className="output-header">
<button type="button">
Unlocks
</button>
<button type="button">Unlocks</button>
</div>
</div>
{
isExpanded && (
<div>
{unlocks.map((unlock, idx) => {
if (unlock.type === UnlockType.Signature) {
{isExpanded && (
<div>
{unlocks.map((unlock, idx) => {
if (unlock.type === UnlockType.Signature) {
const signatureUnlock = unlock as SignatureUnlock;

return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
<div className="unlocks-card--row">
<span className="label">Public Key:</span>
<div className="value public-key">
<TruncatedId id={signatureUnlock.signature.publicKey} showCopyButton />
{displayUnlocksTypeAndIndex(unlock.type, idx)}
<div className="unlocks-card--row">
<span className="label">Public Key:</span>
<div className="value public-key">
<TruncatedId id={signatureUnlock.signature.publicKey} showCopyButton />
</div>
</div>
</div>
<div className="unlocks-card--row">
<span className="label">Signature:</span>
<div className="value signature">
<TruncatedId id={signatureUnlock.signature.signature} showCopyButton />
<div className="unlocks-card--row">
<span className="label">Signature:</span>
<div className="value signature">
<TruncatedId id={signatureUnlock.signature.signature} showCopyButton />
</div>
</div>
</div>
</div>
);
} else if (unlock.type === UnlockType.Multi) {
const multiUnlock = unlock as MultiUnlock;
} else if (unlock.type === UnlockType.Multi) {
const multiUnlock = unlock as MultiUnlock;

return <Unlocks unlocks={multiUnlock.unlocks} key={idx} />;
}
else if (unlock.type === UnlockType.Empty) {
return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
</div>
);
}
else {
const referencedUnlock = unlock as UnlockTypeMap[typeof unlock.type];
return <Unlocks unlocks={multiUnlock.unlocks} key={idx} />;
} else if (unlock.type === UnlockType.Empty) {
return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
</div>
);
} else {
const referencedUnlock = unlock as UnlockTypeMap[typeof unlock.type];

return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
<div className="unlocks-card--row">
<span className="label">References unlock at index:</span>
<span className="value">{referencedUnlock.reference}</span>
</div>
return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
<div className="unlocks-card--row">
<span className="label">References unlock at index:</span>
<span className="value">{referencedUnlock.reference}</span>
</div>
);
}
})}
</div>
)
}
</div>
);
}
})}
</div>
)}
</div>
);
};

export default Unlocks;

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ interface SignedTransactionPayloadProps {
readonly header?: string;
}

const SignedTransactionPayload: React.FC<SignedTransactionPayloadProps> = (
{ payload, inputs, header }
) => {
const SignedTransactionPayload: React.FC<SignedTransactionPayloadProps> = ({ payload, inputs, header }) => {
const { networkId, outputs } = payload.transaction;
const transactionId = Utils.transactionId(payload)
const transactionId = Utils.transactionId(payload);

return (
<div className="transaction-payload">
Expand All @@ -37,7 +35,9 @@ const SignedTransactionPayload: React.FC<SignedTransactionPayloadProps> = (
<span>{inputs.length}</span>
</div>
<div className="transaction-payload_outputs card--content">
{inputs.map((input, idx) => <Input key={idx} network={networkId} input={input} />)}
{inputs.map((input, idx) => (
<Input key={idx} network={networkId} input={input} />
))}
<Unlocks unlocks={payload.unlocks} />
</div>
</div>
Expand Down Expand Up @@ -71,4 +71,3 @@ SignedTransactionPayload.defaultProps = {
};

export default SignedTransactionPayload;

17 changes: 4 additions & 13 deletions client/src/app/components/nova/block/payload/TaggedDataPayload.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { TaggedDataPayload as ITaggedDataPayload} from "@iota/sdk-wasm-nova/web";
import { TaggedDataPayload as ITaggedDataPayload } from "@iota/sdk-wasm-nova/web";
import React from "react";
import DataToggle from "~/app/components/DataToggle";

interface TaggedDataPayloadProps {
readonly payload: ITaggedDataPayload;
}

const TaggedDataPayload: React.FC<TaggedDataPayloadProps> = (
{ payload }
) => {
const TaggedDataPayload: React.FC<TaggedDataPayloadProps> = ({ payload }) => {
const { tag, data } = payload;

return (
Expand All @@ -19,21 +17,15 @@ const TaggedDataPayload: React.FC<TaggedDataPayloadProps> = (
<div className="label row middle">
<span className="margin-r-t">Tag</span>
</div>
<DataToggle
sourceData={tag}
withSpacedHex={true}
/>
<DataToggle sourceData={tag} withSpacedHex={true} />
</React.Fragment>
)}
{data && (
<React.Fragment>
<div className="label row middle">
<span className="margin-r-t">Data</span>
</div>
<DataToggle
sourceData={data}
withSpacedHex={true}
/>
<DataToggle sourceData={data} withSpacedHex={true} />
</React.Fragment>
)}
</div>
Expand All @@ -46,4 +38,3 @@ TaggedDataPayload.defaultProps = {
};

export default TaggedDataPayload;

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
Block, PayloadType, SignedTransactionPayload as ISignedTransactionPayload,
Block,
PayloadType,
SignedTransactionPayload as ISignedTransactionPayload,
TaggedDataPayload as ITaggedDataPayload,
BasicBlockBody
BasicBlockBody,
} from "@iota/sdk-wasm-nova/web";
import React from "react";
import { IInput } from "~models/api/nova/IInput";
Expand All @@ -16,52 +18,35 @@ interface BlockPayloadSectionProps {
readonly transferTotal?: number;
}

const BlockPayloadSection: React.FC<BlockPayloadSectionProps> = (
{ block, inputs, outputs, transferTotal }
) => {
const payload = (block.body as BasicBlockBody).payload
if (
payload?.type === PayloadType.SignedTransaction &&
inputs && outputs && transferTotal !== undefined
) {
const transactionPayload = payload as ISignedTransactionPayload;
const BlockPayloadSection: React.FC<BlockPayloadSectionProps> = ({ block, inputs, outputs, transferTotal }) => {
const payload = (block.body as BasicBlockBody).payload;
if (payload?.type === PayloadType.SignedTransaction && inputs && outputs && transferTotal !== undefined) {
const transactionPayload = payload as ISignedTransactionPayload;
const transaction = transactionPayload.transaction;

return (
<React.Fragment>
<div className="section">
<SignedTransactionPayload
inputs={inputs}
payload={transactionPayload}
/>
<SignedTransactionPayload inputs={inputs} payload={transactionPayload} />
</div>
{
transaction.payload?.type === PayloadType.TaggedData &&
{transaction.payload?.type === PayloadType.TaggedData && (
<div className="section">
<TaggedDataPayload
payload={transaction.payload as ITaggedDataPayload}
/>
<TaggedDataPayload payload={transaction.payload as ITaggedDataPayload} />
</div>
}
)}
</React.Fragment>
);
} else if (
payload?.type === PayloadType.CandidacyAnnouncement
) {
} else if (payload?.type === PayloadType.CandidacyAnnouncement) {
return (
<div>
{/* todo */}
CandidacyAnnouncement
</div>
);
} else if (
payload?.type === PayloadType.TaggedData
) {
} else if (payload?.type === PayloadType.TaggedData) {
return (
<div className="section">
<TaggedDataPayload
payload={payload as ITaggedDataPayload}
/>
<TaggedDataPayload payload={payload as ITaggedDataPayload} />
</div>
);
}
Expand All @@ -76,4 +61,3 @@ BlockPayloadSection.defaultProps = {
};

export default BlockPayloadSection;

Loading

0 comments on commit 85e0497

Please sign in to comment.