-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement display of transaction hashes
- Loading branch information
1 parent
50fa8b9
commit 468e2af
Showing
6 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { TransactionId } from "@penumbra-zone/protobuf/penumbra/core/txhash/v1/txhash_pb"; | ||
import { k12 } from "@noble/hashes/sha3-addons"; | ||
import { Tooltip, TooltipProvider } from "@penumbra-zone/ui/Tooltip"; | ||
import { bytesToHex } from "@noble/hashes/utils"; | ||
|
||
// data -> 64 bit hash -> 16 4bit hue values -> 16 floats in [0, 1] | ||
const fingerprintToHues = (data: Uint8Array): number[] => { | ||
const hash = k12(data, { dkLen: 8 }); | ||
const out: number[] = []; | ||
for (const b of hash) { | ||
out.push((b & 0xf) / 0xf); | ||
out.push(((b >> 4) & 0xf) / 0xf); | ||
} | ||
return out; | ||
}; | ||
|
||
const PixelGrid = ({ hues }: { hues: number[] }) => { | ||
const S = 0.8; | ||
const L = 0.5; | ||
const padded = hues.concat(Array(16).fill(0.0)).slice(0, 16); | ||
const values = padded.map((h, i) => ({ | ||
x: i % 4, | ||
y: Math.floor(i / 4), | ||
h, | ||
key: i, | ||
})); | ||
return ( | ||
<svg viewBox="0 0 4 4" width="1.5em" height="1.5em"> | ||
{values.map((v) => ( | ||
<rect | ||
key={v.key} | ||
width="1" | ||
height="1" | ||
x={v.x} | ||
y={v.y} | ||
fill={`hsl(${v.h * 360}, ${S * 100}%, ${L * 100}%)`} | ||
/> | ||
))} | ||
</svg> | ||
); | ||
}; | ||
|
||
export default ({ transactionId }: { transactionId: TransactionId }) => { | ||
const bytes = transactionId.inner; | ||
return ( | ||
<TooltipProvider> | ||
<Tooltip message={bytesToHex(bytes)}> | ||
<PixelGrid hues={fingerprintToHues(bytes)} /> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// vite.config.ts | ||
import { vitePlugin as remix } from "file:///home/lucas/Work/Penumbra/wheresmyum/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_typ_zaks5nzsgydl2bdmxedpgoukjq/node_modules/@remix-run/dev/dist/index.js"; | ||
import { defineConfig } from "file:///home/lucas/Work/Penumbra/wheresmyum/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/index.js"; | ||
import tsconfigPaths from "file:///home/lucas/Work/Penumbra/wheresmyum/node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_/node_modules/vite-tsconfig-paths/dist/index.mjs"; | ||
var vite_config_default = defineConfig({ | ||
plugins: [ | ||
remix({ | ||
future: { | ||
v3_fetcherPersist: true, | ||
v3_relativeSplatPath: true, | ||
v3_throwAbortReason: true | ||
} | ||
}), | ||
tsconfigPaths() | ||
], | ||
css: { | ||
postcss: true | ||
} | ||
}); | ||
export { | ||
vite_config_default as default | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25ma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