diff --git a/web-app/src/modules/core/routes/Account/Movements/MovementItem.tsx b/web-app/src/modules/core/routes/Account/Movements/MovementItem.tsx index cd60046..f15d285 100644 --- a/web-app/src/modules/core/routes/Account/Movements/MovementItem.tsx +++ b/web-app/src/modules/core/routes/Account/Movements/MovementItem.tsx @@ -1,12 +1,18 @@ import { FC } from 'react'; import { format } from 'date-fns'; -import { BlockMetadataTransaction, Movement, ScriptUserTransaction, TransactionType, UserTransaction } from '../../../../movements'; +import clsx from 'clsx'; +import { + BlockMetadataTransaction, + Movement, + ScriptUserTransaction, + TransactionType, + UserTransaction, +} from '../../../../movements'; import GenesisMovement from './GenesisMovement'; import BlockMetadataMovement from './BlockMetadataMovement'; import UserMovement from './UserMovement'; import LibraAmount from '../../../../ui/LibraAmount'; -import clsx from 'clsx'; const MovementItem: FC<{ movement: Movement }> = ({ movement }) => { const success = diff --git a/web-app/src/modules/ui/AccountAddress/AccountAddress.tsx b/web-app/src/modules/ui/AccountAddress/AccountAddress.tsx index 742566b..c8eeb0b 100644 --- a/web-app/src/modules/ui/AccountAddress/AccountAddress.tsx +++ b/web-app/src/modules/ui/AccountAddress/AccountAddress.tsx @@ -5,7 +5,7 @@ import { toast } from 'react-toastify'; import { normalizeHexString } from '../../../utils'; import HexString from '../HexString'; import CopyIcon from '../Icons/CopyIcon'; -import AddressAvatar from '../AddressAvatar/AddressAvatar'; +import AddressAvatar from '../AddressAvatar'; interface Props { address: string; diff --git a/web-app/src/modules/ui/AddressAvatar/blockies.ts b/web-app/src/modules/ui/AddressAvatar/blockies.ts index 29937ea..6a6c605 100644 --- a/web-app/src/modules/ui/AddressAvatar/blockies.ts +++ b/web-app/src/modules/ui/AddressAvatar/blockies.ts @@ -56,7 +56,8 @@ function createImageData(size: number) { for (let x = 0; x < dataWidth; x++) { // this makes foreground and background color to have a 43% (1/2.3) probability // spot color has 13% chance - row[x] = Math.floor(rand() * 2.3); + const v = Math.floor(rand() * 2.3); + row[x] = v; } const r = row.slice(0, mirrorWidth); r.reverse(); @@ -71,22 +72,21 @@ function createImageData(size: number) { } function buildOpts(opts: Partial): Options { - const newOpts = { + const seed = opts.seed || Math.floor(Math.random() * Math.pow(10, 16)).toString(16); + seedrand(seed); + + return { size: opts.size || 8, scale: opts.scale || 4, color: opts.color || createColor(), bgcolor: opts.bgcolor || createColor(), spotcolor: opts.spotcolor || createColor(), - seed: opts.seed || Math.floor(Math.random() * Math.pow(10, 16)).toString(16), + seed, }; - - seedrand(newOpts.seed); - - return newOpts; } -export function renderIcon(options: Partial, canvas: HTMLCanvasElement) { - let opts = buildOpts(options); +function renderIcon(options: Partial, canvas: HTMLCanvasElement) { + const opts = buildOpts(options); const imageData = createImageData(opts.size); const width = Math.sqrt(imageData.length); @@ -106,7 +106,6 @@ export function renderIcon(options: Partial, canvas: HTMLCanvasElement) // if data is 2, choose spot color, if 1 choose foreground cc.fillStyle = imageData[i] == 1 ? opts.color : opts.spotcolor; - cc.fillRect(col * opts.scale, row * opts.scale, opts.scale, opts.scale); } } diff --git a/web-app/src/modules/ui/AddressAvatar/index.ts b/web-app/src/modules/ui/AddressAvatar/index.ts new file mode 100644 index 0000000..140882f --- /dev/null +++ b/web-app/src/modules/ui/AddressAvatar/index.ts @@ -0,0 +1 @@ +export { default } from "./AddressAvatar";