·
108 commits
to main
since this release
Minor Changes
-
#8289
b30369fThanks @jnsdls! - ###getContractMetadata()now returns a record withunknownvalues instead ofany.before:
const metadata = await getContractMetadata({ contract }); metadata; // Record<string, any> metadata.name; // string metadata.symbol; // string
after:
const metadata = await getContractMetadata({ contract }); metadata; // Record<string, unknown> metadata.name; // string | null metadata.symbol; // string | null
Metadata is not (and was never) strictly defined outside of
nameandsymboland may contain any type of data in the record.
This is not a runtime change but it may break type inference in existing apps that relied on the previous return type.Recommended fix:
You should type-guard any key you access from "metadata".const metadata = await getContractMetadata({ contract }); if ("foo" in metadata && typeof metadata.foo === "string") { metadata.foo; // string }
Quick fix:
If adding type assertions is not something you can do in the short term you can also assert the type directly.
This is as "unsafe" as the type was before.const metadata = await getContractMetadata({ contract }); const foo = metadata.foo as string;
Patch Changes
- #8280
ceba683Thanks @MananTank! - Fix process not defined error when using "thirdweb/contract" import in Vite