Skip to content

Commit aaf8c5f

Browse files
authored
Merge pull request #807 from LIT-Protocol/feat/lit-chain-manager-and-lit-network-components
Feat/lit chain manager and lit network components
2 parents 2610173 + edb6ab7 commit aaf8c5f

File tree

162 files changed

+21688
-3710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+21688
-3710
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Generating Local Network Context for Lit Protocol
2+
3+
The Lit network contexts, which include smart contract addresses and ABIs, typically come from the `@lit-protocol/contracts` package (a separate repository at https://github.com/LIT-Protocol/lit-contracts/). However, these contexts are designed for established networks.
4+
5+
## Local Network Setup
6+
7+
For local development (running Lit nodes on your machine), you need to generate a `networkContext.json` file in the `lit-assets` directory. This is typically done by running the deploy script after starting your local Anvil chain.
8+
9+
## Version Compatibility Changes
10+
11+
In version 7 or earlier, you could simply copy and paste the `networkContext.json` file, and it would work when setting the network to `custom` when running with Tinny (E2E test suite).
12+
13+
However, in version 8, we've optimised by removing redundant and unused ABIs from the JSON file and enforced strongly typed ABIs. This optimization introduced an additional conversion layer that extracts only the necessary ABI methods, which must be run manually for local network contexts.
14+
15+
## Generating Custom Context
16+
17+
To generate the proper context:
18+
19+
1. Locate the `getCustomContext` file in the network-specific folder (in this case, `vNaga/naga-develop` folder)
20+
2. Use the `generateSignaturesFromContext` helper function from the `@lit-protocol/contracts` repository
21+
22+
Here's an example of how to use this function:
23+
24+
```ts
25+
import { generateSignaturesFromContext } from '@lit-protocol/contracts/custom-network-signatures';
26+
27+
await generateSignaturesFromContext({
28+
jsonFilePath:
29+
'/Users/anson/Projects/lit-assets/blockchain/contracts/networkContext.json', // in lit assets repo
30+
networkName: 'naga-develop',
31+
outputDir: './naga-develop-signatures',
32+
useScriptDirectory: true,
33+
callerPath: import.meta.url,
34+
});
35+
```

.ctx/v7-to-v8-migration-notes.md

Whitespace-only changes.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ local-tests/build
7777
packages/wrapped-keys-lit-actions/src/generated
7878

7979
digest
80-
generate-digest.ts
80+
generate-digest.ts
81+
82+
.cursor/rules

jest.setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ const crypto = require('crypto');
33
global.TextEncoder = require('util').TextEncoder;
44
global.TextDecoder = require('util').TextDecoder;
55
global.crypto = crypto;
6+
7+
// If this is not included, you will get the following error when running it in Jest:
8+
// (Error) Details: Request is not defined
9+
// The problem is that Jest is running in a Node.js environment where the global Request API (part of the Fetch API) might not be available or properly configured. Bun, on the other hand, has this API built into its runtime by default, which is why it works.
10+
const { default: fetch, Request, Response } = require('node-fetch');
11+
global.fetch = fetch;
12+
global.Request = Request;
13+
global.Response = Response;

0 commit comments

Comments
 (0)