@@ -2,17 +2,109 @@ import {
22 createPublicClient ,
33 createWalletClient ,
44 getContract ,
5+ Hex ,
56 http ,
67 PublicClient ,
78 WalletClient ,
89} from 'viem' ;
910import { privateKeyToAccount } from 'viem/accounts' ;
1011import { NagaContext } from '../../../../../vNaga/types' ;
11-
12+ import { networkContext as defaultNetworkContext } from '../../_config' ;
1213interface CreateLitContractsOptions {
1314 publicClient ?: PublicClient ;
1415}
1516
17+ // =============================================================================================================================================
18+ // ❗️ These types are required to fix the following error
19+ // ERROR: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)
20+ // If you could fix this WITHOUT breaking this code apart, or without setting the tsconfig's "declaration" to false, please do fix this. 🙏
21+ // =============================================================================================================================================
22+
23+ // Extract just the ContractData type, and you can use this type for variables that will eventually hold contract data
24+ let futureContractData = defaultNetworkContext . chainConfig . contractData ;
25+
26+ const pkpNftContractType = getContract ( {
27+ address : undefined as unknown as Hex ,
28+ abi : [
29+ futureContractData . PKPNFT . methods . claimAndMint ,
30+ futureContractData . PKPNFT . methods . mintCost ,
31+ futureContractData . PKPNFT . methods . tokenOfOwnerByIndex ,
32+ ] ,
33+ client : {
34+ public : undefined as unknown as PublicClient ,
35+ wallet : undefined as unknown as WalletClient ,
36+ } ,
37+ } ) ;
38+
39+ const pkpHelperContractType = getContract ( {
40+ address : undefined as unknown as Hex ,
41+ abi : [
42+ futureContractData . PKPHelper . methods
43+ . claimAndMintNextAndAddAuthMethodsWithTypes ,
44+ futureContractData . PKPHelper . methods . mintNextAndAddAuthMethods ,
45+ ] ,
46+ client : {
47+ public : undefined as unknown as PublicClient ,
48+ wallet : undefined as unknown as WalletClient ,
49+ } ,
50+ } ) ;
51+
52+ const stakingContractType = getContract ( {
53+ address : undefined as unknown as Hex ,
54+ abi : [
55+ futureContractData . Staking . methods
56+ . getActiveUnkickedValidatorStructsAndCounts ,
57+ ] ,
58+ client : {
59+ public : undefined as unknown as PublicClient ,
60+ wallet : undefined as unknown as WalletClient ,
61+ } ,
62+ } ) ;
63+
64+ const priceFeedContractType = getContract ( {
65+ address : undefined as unknown as Hex ,
66+ abi : [ futureContractData . PriceFeed . methods . getNodesForRequest ] ,
67+ client : {
68+ public : undefined as unknown as PublicClient ,
69+ wallet : undefined as unknown as WalletClient ,
70+ } ,
71+ } ) ;
72+
73+ const pkpPermissionsContractType = getContract ( {
74+ address : undefined as unknown as Hex ,
75+ abi : [
76+ futureContractData . PKPPermissions . methods . addPermittedAction ,
77+ futureContractData . PKPPermissions . methods . addPermittedAddress ,
78+ futureContractData . PKPPermissions . methods . getPermittedActions ,
79+ futureContractData . PKPPermissions . methods . getPermittedAddresses ,
80+ futureContractData . PKPPermissions . methods . getPermittedAuthMethods ,
81+ futureContractData . PKPPermissions . methods . getPermittedAuthMethodScopes ,
82+ futureContractData . PKPPermissions . methods . removePermittedAction ,
83+ futureContractData . PKPPermissions . methods . removePermittedAddress ,
84+ futureContractData . PKPPermissions . methods . isPermittedAction ,
85+ futureContractData . PKPPermissions . methods . isPermittedAddress ,
86+ ] ,
87+ client : {
88+ public : undefined as unknown as PublicClient ,
89+ wallet : undefined as unknown as WalletClient ,
90+ } ,
91+ } ) ;
92+
93+ const pubkeyRouterContractType = getContract ( {
94+ address : undefined as unknown as Hex ,
95+ abi : [
96+ futureContractData . PubkeyRouter . methods . deriveEthAddressFromPubkey ,
97+ futureContractData . PubkeyRouter . methods . ethAddressToPkpId ,
98+ futureContractData . PubkeyRouter . methods . getEthAddress ,
99+ futureContractData . PubkeyRouter . methods . getPubkey ,
100+ ] ,
101+ client : {
102+ public : undefined as unknown as PublicClient ,
103+ wallet : undefined as unknown as WalletClient ,
104+ } ,
105+ } ) ;
106+ // Hacky fix ends
107+
16108export const createLitContracts = (
17109 networkCtx : NagaContext ,
18110 opts ?: CreateLitContractsOptions
@@ -121,13 +213,16 @@ export const createLitContracts = (
121213
122214 // ---------- End of all your contracts ----------
123215 return {
124- pkpNftContract,
125- pkpHelperContract,
126- stakingContract,
127- priceFeed,
128- pkpPermissionsContract,
129- pubkeyRouterContract,
216+ pkpNftContract : pkpNftContract as unknown as typeof pkpNftContractType ,
217+ pkpHelperContract :
218+ pkpHelperContract as unknown as typeof pkpHelperContractType ,
219+ stakingContract : stakingContract as unknown as typeof stakingContractType ,
220+ priceFeed : priceFeed as unknown as typeof priceFeedContractType ,
221+ pkpPermissionsContract :
222+ pkpPermissionsContract as unknown as typeof pkpPermissionsContractType ,
223+ pubkeyRouterContract :
224+ pubkeyRouterContract as unknown as typeof pubkeyRouterContractType ,
130225 publicClient,
131226 walletClient,
132- } as const ;
227+ } ;
133228} ;
0 commit comments