diff --git a/next.config.js b/next.config.js index 258a3d470..54ce3c472 100644 --- a/next.config.js +++ b/next.config.js @@ -14,8 +14,8 @@ const securityHeaders = [ process.env.NODE_ENV === "development" ? `'unsafe-eval'` : "" };` + `style-src 'self' fonts.googleapis.com 'unsafe-inline';` + - `font-src fonts.gstatic.com;` + - `connect-src 'self' ocean.defichain.com 35.241.191.23:3000 *.jellyfishsdk.com playground.jellyfishsdk.com wallet.defichain.com; ${ + `font-src fonts.gstatic.com data:;` + + `connect-src 'self' ocean.defichain.com 35.241.191.23:3000 *.jellyfishsdk.com playground.jellyfishsdk.com wallet.defichain.com ${ process.env.NODE_ENV === "development" ? `ws://localhost:3000/_next/webpack-hmr` : "" diff --git a/src/pages/transactions/[txid].page.tsx b/src/pages/transactions/[txid].page.tsx index a7449bc2f..8ebf51b9f 100644 --- a/src/pages/transactions/[txid].page.tsx +++ b/src/pages/transactions/[txid].page.tsx @@ -31,6 +31,7 @@ import { TransactionSummaryTable } from "./_components/TransactionSummaryTable"; import { TransactionDfTx } from "./_components/TransactionDfTx"; import { isAlphanumeric } from "../../utils/commons/StringValidator"; import { RawTransaction } from "./_components/RawTransaction"; +import { RawAccountHistory } from "./_components/RawAccountHistory"; interface TransactionPageProps { txid: string; @@ -103,6 +104,7 @@ export default function TransactionPage( isEvmTx={isEvmTx} /> + ); diff --git a/src/pages/transactions/_components/RawAccountHistory.tsx b/src/pages/transactions/_components/RawAccountHistory.tsx new file mode 100644 index 000000000..4f8364893 --- /dev/null +++ b/src/pages/transactions/_components/RawAccountHistory.tsx @@ -0,0 +1,111 @@ +import { useWhaleApiClient } from "@contexts/WhaleContext"; +import { Transaction } from "@defichain/whale-api-client/dist/api/transactions"; +import { ReactElement, useCallback, useState } from "react"; + +export function RawAccountHistory(props: { + transaction: Transaction; +}): ReactElement { + return ( +
+

Raw Account History

+ +

+ Query raw defid account state at TxId:{" "} + + {props.transaction.txid} + {" "} + and TxNo:{" "} + + {props.transaction.order} + +

+ + +
+ ); +} + +function QueryAddressHistory(props: { + transaction: Transaction; +}): ReactElement { + const api = useWhaleApiClient(); + const [address, setAddress] = useState(); + const [response, setResponse] = useState(); + + const onClick = useCallback(() => { + if (address === undefined) { + setResponse("Address is required"); + return; + } + + api.address + .getAccountHistory( + address, + props.transaction.block.height, + props.transaction.order, + ) + .then((response) => { + setResponse(response); + }) + .catch((e) => { + setResponse(e); + }); + }, [address]); + + return ( +
+
+ setAddress(e.target.value)} + /> + +
+ + {response !== undefined && ( +
+
{JSON.stringify(response, null, 2)}
+
+ )} +
+ ); +} + +// function decodeAddresses (options: { +// network: string +// vins: TransactionVin[]; +// vouts: TransactionVout[]; +// }): string[] { +// const addresses = new Set() +// +// for (const vin of options.vins) { +// if (vin.vout?.script?.hex === undefined) { +// continue +// } +// const address = fromScriptHex(vin.vout.script.hex!, options.network) +// if (address !== undefined) { +// addresses.add(address.address) +// } +// } +// +// for (const vout of options.vouts) { +// if (vout.script?.hex === undefined) { +// continue +// } +// const address = fromScriptHex(vout.script.hex!, options.network) +// if (address !== undefined) { +// addresses.add(address.address) +// } +// } +// return Array.from(addresses) +// }