Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f59121d

Browse files
committed
fix(networks, schemas): fix build by adding the required StrictAuth data. This changes are added in #891 and #892 but they are pull in so this PR can build
1 parent 9d8d389 commit f59121d

File tree

5 files changed

+25017
-14
lines changed

5 files changed

+25017
-14
lines changed

packages/networks/src/networks/vNaga/shared/factories/BaseChainManagerFactory.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '../interfaces/NetworkContext';
1010
import type { PKPStorageProvider } from '../../../../storage/types';
1111
import { DEV_PRIVATE_KEY } from '@lit-protocol/constants';
12+
import { AuthData, StrictAuthData } from '@lit-protocol/schemas';
1213

1314
export type CreateChainManagerReturn = {
1415
api: {
@@ -26,11 +27,7 @@ export type CreateChainManagerReturn = {
2627
) => InstanceType<typeof api.PKPPermissionsManager>;
2728
paymentManager: () => InstanceType<typeof api.PaymentManager>;
2829
getPKPsByAuthData: (
29-
authData: {
30-
authMethodType: number | bigint;
31-
authMethodId: string;
32-
accessToken?: string;
33-
},
30+
authData: StrictAuthData | AuthData,
3431
pagination?: { limit?: number; offset?: number },
3532
storageProvider?: PKPStorageProvider
3633
) => ReturnType<typeof api.PKPPermissionsManager.getPKPsByAuthData>;
@@ -78,6 +75,15 @@ export const createChainManagerFactory = <T, M>(
7875
fn(req, _networkConfig, accountOrWalletClient);
7976
};
8077

78+
const bindAccount = <ReqArgType, RetType>(
79+
fn: (
80+
req: ReqArgType,
81+
accountOrWalletClient: ExpectedAccountOrWalletClient
82+
) => RetType
83+
) => {
84+
return (req: ReqArgType): RetType => fn(req, accountOrWalletClient);
85+
};
86+
8187
return {
8288
api: {
8389
mintWithEoa: bindContext(api.mintWithEoa),
@@ -135,8 +141,8 @@ export const createChainManagerFactory = <T, M>(
135141
);
136142
},
137143
pricing: {
138-
getPriceFeedInfo: bindContext(api.pricing.getPriceFeedInfo),
139-
getNodePrices: bindContext(api.pricing.getNodePrices),
144+
getPriceFeedInfo: bindAccount(api.pricing.getPriceFeedInfo),
145+
getNodePrices: bindAccount(api.pricing.getNodePrices),
140146
},
141147
connection: {
142148
getConnectionInfo: (args?: {

packages/networks/src/networks/vNaga/shared/managers/LitChainClient/apis/highLevelApis/connection/getConnectionInfo.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ export async function getConnectionInfo({
7373
realmId: networkCtx.networkSpecificConfigs.realmId,
7474
networkCtx: networkCtx,
7575
},
76-
{
77-
accountOrWalletClient,
78-
}
76+
accountOrWalletClient
7977
);
8078

8179
const epochState = {

packages/networks/src/networks/vNaga/shared/managers/LitChainClient/apis/rawContractApis/permissions/utils/resolvePkpTokenId.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { logger } from '../../../../../../../../shared/logger';
99
import { DefaultNetworkConfig } from '../../../../../../../shared/interfaces/NetworkContext';
1010
import {
1111
createContractsManager,
12+
createReadOnlyContractsManager,
1213
ExpectedAccountOrWalletClient,
1314
} from '../../../../../contract-manager/createContractsManager';
1415
import { pubkeyToTokenId } from './pubkeyToTokenId';
@@ -110,10 +111,11 @@ export async function resolvePkpTokenId(
110111
throw new Error('Network context required for address resolution');
111112
}
112113

113-
const { pubkeyRouterContract } = createContractsManager(
114-
networkCtx,
115-
accountOrWalletClient
116-
);
114+
// never pass undefined; fall back to read-only
115+
const { pubkeyRouterContract } = accountOrWalletClient
116+
? createContractsManager(networkCtx, accountOrWalletClient)
117+
: createReadOnlyContractsManager(networkCtx);
118+
117119
const pkpTokenId = await pubkeyRouterContract.read.ethAddressToPkpId([
118120
validatedInput.address as `0x${string}`,
119121
]);

packages/schemas/src/lib/auth/auth-schemas.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ import {
77
SessionKeyUriSchema,
88
} from '../schemas';
99

10+
export const CustomAuthDataSchema = z.object({
11+
authMethodId: HexPrefixedSchema,
12+
authMethodType: z.bigint(),
13+
});
14+
15+
export type CustomAuthData = z.infer<typeof CustomAuthDataSchema>;
16+
17+
export const StrictAuthDataSchema = z.object({
18+
authMethodId: HexPrefixedSchema,
19+
authMethodType: z.union([
20+
AuthMethodSchema.shape.authMethodType,
21+
z.number(),
22+
z.bigint(),
23+
]),
24+
accessToken: AuthMethodSchema.shape.accessToken,
25+
});
26+
27+
export type StrictAuthData = z.infer<typeof StrictAuthDataSchema>;
28+
1029
export const AuthDataSchema = z.object({
1130
authMethodId: HexPrefixedSchema,
1231
authMethodType: z.union([

0 commit comments

Comments
 (0)