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" ;
4+ import { type Address , isAddress } from "../utils/address.js" ;
55
66/**
77 * @contract
88 */
9- export type ContractOptions < abi extends Abi = [ ] > = {
9+ export type ContractOptions <
10+ abi extends Abi = [ ] ,
11+ address extends string = string ,
12+ > = {
1013 client : ThirdwebClient ;
11- address : string ;
14+ address : address ;
1215 chain : Chain ;
1316 readonly abi ?: abi ;
1417} ;
1518
1619/**
1720 * @contract
1821 */
19- export type ThirdwebContract < abi extends Abi = [ ] > = Readonly <
20- ContractOptions < abi >
21- > ;
22+ export type ThirdwebContract <
23+ abi extends Abi = [ ] ,
24+ address extends string = string ,
25+ > = Readonly < ContractOptions < abi , address > > ;
2226
2327/**
2428 * Creates a Thirdweb contract by combining the Thirdweb client and contract options.
@@ -42,7 +46,7 @@ export type ThirdwebContract<abi extends Abi = []> = Readonly<
4246 */
4347export function getContract < const abi extends Abi = [ ] > (
4448 options : ContractOptions < abi > ,
45- ) : ThirdwebContract < abi > {
49+ ) : ThirdwebContract < abi , Address > {
4650 if ( ! options . client ) {
4751 throw new Error (
4852 `getContract validation error - invalid client: ${ options . client } ` ,
@@ -58,5 +62,5 @@ export function getContract<const abi extends Abi = []>(
5862 `getContract validation error - invalid chain: ${ options . chain } ` ,
5963 ) ;
6064 }
61- return options ;
65+ return options as ThirdwebContract < abi , Address > ;
6266}
0 commit comments