Skip to content

Commit 2c703e8

Browse files
committed
fix(linter): pkp, pricing and staking directories
1 parent f50fca9 commit 2c703e8

File tree

13 files changed

+108
-95
lines changed

13 files changed

+108
-95
lines changed

packages/constants/src/lib/constants/mappers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _nagaDev } from '@lit-protocol/contracts';
1+
import { nagaDev } from '@lit-protocol/contracts';
22

33
import {
44
LIT_NETWORK,
@@ -12,9 +12,9 @@ import {
1212
*/
1313
export const NETWORK_CONTEXT_BY_NETWORK: Record<
1414
LIT_NETWORK_VALUES,
15-
typeof _nagaDev | undefined
15+
typeof nagaDev | undefined
1616
> = {
17-
[LIT_NETWORK.NagaDev]: _nagaDev,
17+
[LIT_NETWORK.NagaDev]: nagaDev,
1818
[LIT_NETWORK.Custom]: undefined,
1919
} as const;
2020

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { pino } from 'pino';
2+
import pinoCaller from 'pino-caller';
3+
4+
const baseLogger = pino({
5+
level: process.env['LOG_LEVEL'] ?? 'info',
6+
transport: {
7+
target: 'pino-pretty',
8+
options: { colorize: true, translateTime: true },
9+
},
10+
});
11+
12+
export const logger = pinoCaller(baseLogger);

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pkp/read/getPubkeyByTokenId.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
2-
import { logger } from "utils/logger";
3-
import { z } from "zod";
4-
import { createLitContracts } from "../../../utils/createLitContracts";
1+
import { NagaContext } from '../../../../../../types';
2+
import { z } from 'zod';
3+
import { createLitContracts } from '../../../utils/createLitContracts';
4+
import { logger } from '../../../../../../../shared/logger';
55

66
// Schema for the request
77
const getPubkeyByTokenIdSchema = z.object({
@@ -22,7 +22,7 @@ export async function getPubkeyByTokenId(
2222
): Promise<string> {
2323
const { tokenId } = getPubkeyByTokenIdSchema.parse(request);
2424

25-
logger.debug({ tokenId }, "Fetching public key by token ID");
25+
logger.debug({ tokenId }, 'Fetching public key by token ID');
2626

2727
// Create contract instances
2828
const { pubkeyRouterContract } = createLitContracts(networkCtx);
@@ -36,7 +36,7 @@ export async function getPubkeyByTokenId(
3636
// Ensure the result is a string
3737
const publicKey = result.toString();
3838

39-
logger.debug({ tokenId, publicKey }, "Public key fetched");
39+
logger.debug({ tokenId, publicKey }, 'Public key fetched');
4040

4141
return publicKey;
4242
}

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pkp/read/tokenOfOwnerByIndex.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// import { networkContext } from "../../../_config";
2-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
3-
import { logger } from "utils/logger";
4-
import { z } from "zod";
5-
import { createLitContracts } from "../../../utils/createLitContracts";
1+
import { logger } from '../../../../../../../shared/logger';
2+
import { NagaContext } from '../../../../../../types';
3+
import { z } from 'zod';
4+
import { createLitContracts } from '../../../utils/createLitContracts';
65

76
// Schema for the request
87
const tokenOfOwnerByIndexSchema = z.object({
9-
ownerAddress: z.string().startsWith("0x"),
8+
ownerAddress: z.string().startsWith('0x'),
109
index: z.number().int().nonnegative(),
1110
});
1211

@@ -24,7 +23,7 @@ export async function tokenOfOwnerByIndex(
2423
): Promise<string> {
2524
const { ownerAddress, index } = tokenOfOwnerByIndexSchema.parse(request);
2625

27-
logger.debug({ ownerAddress, index }, "Fetching token of owner by index");
26+
logger.debug({ ownerAddress, index }, 'Fetching token of owner by index');
2827

2928
// Create contract instances
3029
const { pkpNftContract } = createLitContracts(networkCtx);
@@ -44,12 +43,12 @@ export async function tokenOfOwnerByIndex(
4443

4544
logger.debug(
4645
{ ownerAddress, index, tokenId },
47-
"Token of owner by index fetched"
46+
'Token of owner by index fetched'
4847
);
4948

5049
return tokenId;
5150
} catch (e) {
52-
throw new Error("Error fetching token of owner by index");
51+
throw new Error('Error fetching token of owner by index');
5352
}
5453
}
5554

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pkp/write/claimAndMint.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
1+
import { NagaContext } from '../../../../../../types';
22
import {
33
ClaimAndMintRaw,
44
ClaimAndMintSchema,
5-
} from "../../../../schemas/ClaimAndMintSchema";
5+
} from '../../../../schemas/ClaimAndMintSchema';
66
import {
77
PKPData,
88
PKPDataSchema,
9-
} from "../../../../schemas/shared/PKPDataSchema";
10-
import { LitTxRes } from "../../../types";
11-
import { callWithAdjustedOverrides } from "../../../utils/callWithAdjustedOverrides";
12-
import { createLitContracts } from "../../../utils/createLitContracts";
13-
import { decodeLogs } from "../../../utils/decodeLogs";
14-
9+
} from '../../../../schemas/shared/PKPDataSchema';
10+
import { LitTxRes } from '../../../types';
11+
import { callWithAdjustedOverrides } from '../../../utils/callWithAdjustedOverrides';
12+
import { createLitContracts } from '../../../utils/createLitContracts';
13+
import { decodeLogs } from '../../../utils/decodeLogs';
1514
export async function claimAndMint(
1615
request: ClaimAndMintRaw,
1716
networkCtx: NagaContext
@@ -29,18 +28,26 @@ export async function claimAndMint(
2928

3029
const hash = await callWithAdjustedOverrides(
3130
pkpNftContract,
32-
"claimAndMint",
33-
[ECDSA_SECP256K1, derivedKeyId, signatures, stakingContract.address],
31+
'claimAndMint',
32+
[
33+
networkCtx.realmId,
34+
ECDSA_SECP256K1,
35+
derivedKeyId,
36+
signatures,
37+
stakingContract.address,
38+
],
3439
{
3540
value: mintCost,
41+
account: null,
42+
chain: null,
3643
}
3744
);
3845

3946
const receipt = await publicClient.waitForTransactionReceipt({ hash });
4047

4148
const decodedLogs = await decodeLogs(receipt.logs, networkCtx);
4249

43-
const args = decodedLogs.find((log) => log.eventName === "PKPMinted")?.args;
50+
const args = decodedLogs.find((log) => log.eventName === 'PKPMinted')?.args;
4451

4552
const data = PKPDataSchema.parse(args);
4653

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pkp/write/claimAndMintNextAndAddAuthMethodsWithTypes.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
1+
import { NagaContext } from '../../../../../../types';
22
import {
33
ClaimRequestRaw,
44
ClaimRequestSchema,
5-
} from "../../../../schemas/ClaimRequestSchema";
6-
import { PKPData, PKPDataSchema } from "../../../../schemas/shared/PKPDataSchema";
7-
import { LitTxRes } from "../../../types";
8-
import { callWithAdjustedOverrides } from "../../../utils/callWithAdjustedOverrides";
9-
import { createLitContracts } from "../../../utils/createLitContracts";
10-
import { decodeLogs } from "../../../utils/decodeLogs";
5+
} from '../../../../schemas/ClaimRequestSchema';
6+
import {
7+
PKPData,
8+
PKPDataSchema,
9+
} from '../../../../schemas/shared/PKPDataSchema';
10+
import { LitTxRes } from '../../../types';
11+
import { callWithAdjustedOverrides } from '../../../utils/callWithAdjustedOverrides';
12+
import { createLitContracts } from '../../../utils/createLitContracts';
13+
import { decodeLogs } from '../../../utils/decodeLogs';
1114

1215
/**
1316
* Claims and mints a PKP using derived key ID and signatures, then adds authentication methods.
@@ -60,10 +63,12 @@ export async function claimAndMintNextAndAddAuthMethodsWithTypes(
6063

6164
const hash = await callWithAdjustedOverrides(
6265
pkpHelperContract,
63-
"claimAndMintNextAndAddAuthMethodsWithTypes",
66+
'claimAndMintNextAndAddAuthMethodsWithTypes',
6467
[claimMaterial, authMethodData],
6568
{
6669
value: mintCost,
70+
account: null,
71+
chain: null,
6772
}
6873
);
6974

@@ -77,7 +82,7 @@ export async function claimAndMintNextAndAddAuthMethodsWithTypes(
7782
// pubkey: "0x045fb12df3d5c8482ab64f7cef10b7c44f9a55256e14ffe8bebe0c526279daa8379fd576b5ea5d26bc0b0973a1260138dfce3951b83378414acf8fe02fea299ccf",
7883
// },
7984
// },
80-
const args = decodedLogs.find((log) => log.eventName === "PKPMinted")?.args;
85+
const args = decodedLogs.find((log) => log.eventName === 'PKPMinted')?.args;
8186

8287
const data = PKPDataSchema.parse(args);
8388

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pkp/write/mintNextAndAddAuthMethods.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
1+
import { NagaContext } from '../../../../../../types';
22
import {
33
MintRequestRaw,
44
MintRequestSchema,
5-
} from "../../../../schemas/MintRequestSchema";
5+
} from '../../../../schemas/MintRequestSchema';
66
import {
77
PKPData,
88
PKPDataSchema,
9-
} from "../../../../schemas/shared/PKPDataSchema";
10-
import { LitTxRes } from "../../../types";
11-
import { callWithAdjustedOverrides } from "../../../utils/callWithAdjustedOverrides";
12-
import { createLitContracts } from "../../../utils/createLitContracts";
13-
import { decodeLogs } from "../../../utils/decodeLogs";
9+
} from '../../../../schemas/shared/PKPDataSchema';
10+
import { LitTxRes } from '../../../types';
11+
import { callWithAdjustedOverrides } from '../../../utils/callWithAdjustedOverrides';
12+
import { createLitContracts } from '../../../utils/createLitContracts';
13+
import { decodeLogs } from '../../../utils/decodeLogs';
1414

1515
/**
1616
* Mints a new Programmable Key Pair (PKP) with specified authentication methods.
@@ -39,7 +39,7 @@ export async function mintNextAndAddAuthMethods(
3939

4040
const hash = await callWithAdjustedOverrides(
4141
pkpHelperContract,
42-
"mintNextAndAddAuthMethods",
42+
'mintNextAndAddAuthMethods',
4343
[
4444
validatedRequest.keyType,
4545
validatedRequest.permittedAuthMethodTypes,
@@ -51,6 +51,8 @@ export async function mintNextAndAddAuthMethods(
5151
],
5252
{
5353
value: mintCost,
54+
account: null,
55+
chain: null,
5456
}
5557
);
5658

@@ -65,7 +67,7 @@ export async function mintNextAndAddAuthMethods(
6567
// pubkey: "0x045fb12df3d5c8482ab64f7cef10b7c44f9a55256e14ffe8bebe0c526279daa8379fd576b5ea5d26bc0b0973a1260138dfce3951b83378414acf8fe02fea299ccf",
6668
// },
6769
// },
68-
const args = decodedLogs.find((log) => log.eventName === "PKPMinted")?.args;
70+
const args = decodedLogs.find((log) => log.eventName === 'PKPMinted')?.args;
6971

7072
const data = PKPDataSchema.parse(args);
7173

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/pricing/getNodesForRequest.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { z } from "zod";
2-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
3-
import { createLitContracts } from "../../utils/createLitContracts";
4-
import { networkContext } from "../../../_config";
5-
import { generateValidatorURLs } from "services/lit/utils/transformers";
1+
import { z } from 'zod';
2+
import { generateValidatorURLs } from '../../../../../../shared/utils/transformers';
3+
import { NagaContext } from '../../../../../types';
4+
import { createLitContracts } from '../../utils/createLitContracts';
65

76
/**
87
* Product IDs used for price feed and node selection
@@ -68,11 +67,11 @@ export async function getNodesForRequest(
6867
};
6968
}
7069

71-
if (import.meta.main) {
72-
const networkCtx = networkContext;
73-
const res = await getNodesForRequest(
74-
{ productIds: Object.values(PRODUCT_IDS) },
75-
networkCtx
76-
);
77-
console.log(res);
78-
}
70+
// if (import.meta.main) {
71+
// const networkCtx = networkContext;
72+
// const res = await getNodesForRequest(
73+
// { productIds: Object.values(PRODUCT_IDS) },
74+
// networkCtx
75+
// );
76+
// console.log(res);
77+
// }

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/staking/getActiveUnkickedValidatorStructsAndCounts.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { beforeAll, describe, expect, test } from "bun:test";
2-
import { networkContext, NetworkContext } from "../../../_config";
3-
import { getActiveUnkickedValidatorStructsAndCounts } from "./getActiveUnkickedValidatorStructsAndCounts";
4-
import { JSONStringify } from "json-with-bigint";
1+
import { beforeAll, describe, expect, test } from 'bun:test';
2+
import { networkContext, NetworkContext } from '../../../_config';
3+
import { getActiveUnkickedValidatorStructsAndCounts } from './getActiveUnkickedValidatorStructsAndCounts';
54

6-
describe("LitChainClient", () => {
5+
describe('LitChainClient', () => {
76
let networkCtx: NetworkContext;
87

98
beforeAll(async () => {
@@ -22,11 +21,13 @@ describe("LitChainClient", () => {
2221
// minNodeCount: 2,
2322
// validatorURLs: [ "https://15.235.83.220:7470", "https://15.235.83.220:7472", "https://15.235.83.220:7471" ],
2423
// }
25-
test("getActiveUnkickedValidatorStructsAndCounts", async () => {
24+
test('getActiveUnkickedValidatorStructsAndCounts', async () => {
2625
const res = await getActiveUnkickedValidatorStructsAndCounts(networkCtx);
2726
console.log(res);
2827
expect(res.minNodeCount).toBeGreaterThanOrEqual(2);
2928
expect(res.epochInfo.epochLength).toBeGreaterThan(0);
30-
expect(res.validatorURLs.length).toBeGreaterThanOrEqual(Number(res.minNodeCount));
31-
})
32-
})
29+
expect(res.validatorURLs.length).toBeGreaterThanOrEqual(
30+
Number(res.minNodeCount)
31+
);
32+
});
33+
});

packages/networks/src/lib/networks/vNaga/common/LitChainClient/apis/rawContractApis/staking/getActiveUnkickedValidatorStructsAndCounts.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { networkContext } from "../../../_config";
2-
import { NagaContext } from "services/lit/LitNetwork/vNaga/types";
3-
import { GetActiveUnkickedValidatorStructsAndCountsSchema } from "../../../schemas/GetActiveUnkickedValidatorStructsAndCountsSchema";
4-
import { createLitContracts } from "../../utils/createLitContracts";
1+
import { NagaContext } from '../../../../../types';
2+
import { GetActiveUnkickedValidatorStructsAndCountsSchema } from '../../../schemas/GetActiveUnkickedValidatorStructsAndCountsSchema';
3+
import { createLitContracts } from '../../utils/createLitContracts';
54

65
// const REALM_ID = 1n;
76

@@ -40,8 +39,8 @@ export async function getActiveUnkickedValidatorStructsAndCounts(
4039
// minNodeCount: 2,
4140
// validatorURLs: [ "https://15.235.83.220:7470", "https://15.235.83.220:7472", "https://15.235.83.220:7471" ],
4241
// }
43-
if (import.meta.main) {
44-
const networkCtx = networkContext;
45-
const res = await getActiveUnkickedValidatorStructsAndCounts(networkCtx);
46-
console.log(res);
47-
}
42+
// if (import.meta.main) {
43+
// const networkCtx = networkContext;
44+
// const res = await getActiveUnkickedValidatorStructsAndCounts(networkCtx);
45+
// console.log(res);
46+
// }

0 commit comments

Comments
 (0)