File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
packages/thirdweb/src/contract Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Validate getContract params
Original file line number Diff line number Diff line change 11import type { Abi } from "abitype" ;
22import type { Chain } from "../chains/types.js" ;
33import type { ThirdwebClient } from "../client/client.js" ;
4+ import { isAddress } from "../utils/address.js" ;
45
56/**
67 * @contract
@@ -42,5 +43,14 @@ export type ThirdwebContract<abi extends Abi = []> = Readonly<
4243export function getContract < const abi extends Abi = [ ] > (
4344 options : ContractOptions < abi > ,
4445) : ThirdwebContract < abi > {
46+ if ( ! options . client ) {
47+ throw new Error ( "getContract validation error: Client is required" ) ;
48+ }
49+ if ( ! isAddress ( options . address ) ) {
50+ throw new Error ( "getContract validation error: Invalid address" ) ;
51+ }
52+ if ( ! options . chain || ! options . chain . id ) {
53+ throw new Error ( "getContract validation error: Chain is required" ) ;
54+ }
4555 return options ;
4656}
You can’t perform that action at this time.
0 commit comments