Files
js/apps/playground-web/src/components/blockchain-api/read-contract-raw.tsx
T
jnsdls 495aa042ba ts 5.6 and other updates (#4522)
<!-- start pr-codex -->

## PR-Codex overview
The focus of this PR is to update dependencies across multiple packages and fix minor code issues.

### Detailed summary
- Updated `typedoc` to versions `0.26.7`.
- Updated `tsup` to versions `8.2.4`.
- Updated `typescript` to versions `5.6.2`.
- Updated various packages to use the latest TypeScript version.
- Fixed minor code issues like handling `delete` operations and eslint comments.

> The following files were skipped due to too many changes: `packages/thirdweb/src/wallets/in-app/core/eip5972/in-app-wallet-calls.ts`, `legacy_packages/wallets/src/evm/connectors/gcp-kms/utils/gcp-kms-utils.ts`, `apps/dashboard/package.json`, `packages/thirdweb/package.json`, `legacy_packages/contracts-js/package.json`, `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
2024-09-11 02:35:34 +00:00

37 lines
1.0 KiB
TypeScript

"use client";
import { THIRDWEB_CLIENT } from "@/lib/client";
import { getContract } from "thirdweb";
import { ethereum } from "thirdweb/chains";
import { MediaRenderer, useReadContract } from "thirdweb/react";
const onChainCryptoPunks = getContract({
address: "0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2",
chain: ethereum,
client: THIRDWEB_CLIENT,
});
function encodeUriData(dataUri: string): string {
const dataStart = dataUri.indexOf(",") + 1;
return (
dataUri.slice(0, dataStart) +
encodeURIComponent(dataUri.slice(dataStart)) || ""
);
}
export function ReadContractRawPreview() {
// Read the image of the tokenId #1
const { data } = useReadContract({
contract: onChainCryptoPunks,
method: "function punkImageSvg(uint16 index) view returns (string svg)",
params: [1],
from: "0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2",
});
return (
<div className="rounded-2xl bg-secondary shadow-xl border">
<MediaRenderer client={THIRDWEB_CLIENT} src={encodeUriData(data ?? "")} />
</div>
);
}