Skip to content

Commit

Permalink
fix: identicon for SCs - fixed #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ohager committed Mar 8, 2022
1 parent 2308b8e commit aea24ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/app/templates/SignumSignView/TransactionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC, memo, useMemo } from 'react';
import classNames from 'clsx';

import HashShortView from 'app/atoms/HashShortView';
import Identicon from 'app/atoms/Identicon';
import IdenticonSignum from 'app/atoms/IdenticonSignum';
import Money from 'app/atoms/Money';
import { t } from 'lib/i18n/react';
Expand Down Expand Up @@ -54,7 +55,11 @@ const ExpenseViewItem: FC<ExpenseViewItemProps> = ({ expense, last, mainnet = fa
return (
<div className={classNames('pt-3 pb-2 px-2 flex justify-start items-center', !last && 'border-b border-gray-200')}>
<div className="mr-2">
<IdenticonSignum address={expense.to} size={40} className="shadow-xs" />
{expense.hash ? (
<Identicon hash={expense.hash} type="bottts" size={40} className="shadow-xs" />
) : (
<IdenticonSignum address={expense.to} size={40} className="shadow-xs" />
)}
</div>

<div className="flex-1 flex-col">
Expand Down
27 changes: 21 additions & 6 deletions src/lib/temple/front/parseSignumTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type ParsedTransactionExpense = {
tokenAddress?: string;
tokenId?: string;
aliasName?: string;
hash?: string;
amount: BigNumber;
to: string;
};
Expand Down Expand Up @@ -135,12 +136,26 @@ function parseMiningExpenses(tx: Transaction): ParsedTransactionExpense[] {
}

function parseContractExpenses(tx: Transaction): ParsedTransactionExpense[] {
return [
{
to: tx.recipient!,
amount: new BigNumber(tx?.amountNQT || 0)
}
];
const amount = new BigNumber(tx?.amountNQT || 0);

switch (tx.subtype) {
case TransactionSmartContractSubtype.SmartContractCreation:
return [
{
to: '',
hash: tx.referencedTransactionFullHash || tx.senderPublicKey!,
amount
}
];
case TransactionSmartContractSubtype.SmartContractPayment:
default:
return [
{
to: tx.recipient!,
amount
}
];
}
}

function parseArbitraryExpenses(tx: Transaction): ParsedTransactionExpense[] {
Expand Down

0 comments on commit aea24ca

Please sign in to comment.