Skip to content

Feat/rc naga 2025 04 07 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
29116c5
refactor
Ansonhkg Feb 19, 2025
6f22b42
feat: use zod and type envs
Ansonhkg Feb 19, 2025
c3b40be
split into several modules
Ansonhkg Feb 19, 2025
3efd818
feat: add tests, cjs, js exports
Ansonhkg Feb 19, 2025
e52c670
feat: comment out failed networks
Ansonhkg Feb 19, 2025
af9dd63
feat: make DEV_PATH_BY_NETWORK
Ansonhkg Feb 19, 2025
dcdc897
feat: add signature export
Ansonhkg Feb 19, 2025
6a53cea
fix: update signatures object format
Ansonhkg Feb 19, 2025
953dd69
feat: better structure
Ansonhkg Feb 19, 2025
513b307
chore: update signatures
Ansonhkg Mar 7, 2025
73bb476
feat: add new methods to extract
Ansonhkg Mar 7, 2025
ff2bed9
feat: add `generateSignaturesFromContext` function so that in our JS-…
Ansonhkg Mar 7, 2025
550a723
fix: add signature to type
Ansonhkg Mar 7, 2025
fa61d59
wip
Ansonhkg Mar 7, 2025
5f35ffe
fix: change the formatting to match the signatures
Ansonhkg Mar 7, 2025
56ea712
feat: add `./custom-network-signatures` path
Ansonhkg Mar 12, 2025
3f08753
feat: add custom-network-signatures
Ansonhkg Mar 13, 2025
ba9ebe3
chore(package.json): re-org custom-network-signatures export
Ansonhkg Mar 13, 2025
04de2e8
feat(typechain): add commented-out code for typechain (if necessary)
Ansonhkg Mar 13, 2025
784991d
feat(network): add naga-dev support
Ansonhkg Apr 10, 2025
db8bfac
feat: fix and generate types properly
Ansonhkg May 8, 2025
a6bcbb9
chore: update output
Ansonhkg May 8, 2025
91ce052
feat: add `PKPNFT.mintNext`
Ansonhkg May 22, 2025
a5e4ec1
feat: add addPermittedAuthMethodScope
Ansonhkg May 24, 2025
f9f63c1
feat: add `getTokenIdsForAuthMethod` and `safeTransferFrom` functions
Ansonhkg May 25, 2025
1e04cad
feat: add `getTokenIdsForAuthMethod`
Ansonhkg May 28, 2025
97e9a0f
publish: 0.1.21
Ansonhkg May 28, 2025
0598595
0.0.27
Ansonhkg May 30, 2025
6bd1773
feat: update naga-staging
Ansonhkg Jun 3, 2025
8e79c8e
chore: bump 0.1.29
Ansonhkg Jun 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions json.d.ts

This file was deleted.

150 changes: 101 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,132 @@
# Fetch Lit contracts and have the same format as general-worker

To run locally, use the following command:

Ensure you have a fine-grain read-only personal access token for the `lit-assets` repository (`GH_LIT_ASSETS_READ_ONLY_API`). For the `LIT_ABI_SOURCE` environment variable, you can set it to either `prod` or `dev`.

- `prod`: Pulls content from the stable network contracts and ABIs found in the [LIT Protocol networks repository](https://github.com/LIT-Protocol/networks).
- `dev`: Pulls content from the [LIT Protocol lit-assets repository](https://github.com/LIT-Protocol/lit-assets), a private repository with frequently changing ABIs and addresses, likely used for internal development.
# Lit Protocol Contract Fetcher

A TypeScript utility for fetching and caching Lit Protocol contract ABIs and addresses. This tool maintains consistent contract data formats across the Lit Protocol ecosystem.

## Architecture

```mermaid
flowchart TB
subgraph Main Process
main["main()"] --> procProd["Process Production Networks"]
main --> procDev["Process Development Networks"]
main --> genIndex["Generate Index File"]
main --> summary["Print Network Summary"]
end

subgraph Production Flow
procProd --> |"For each network"| updateProdCache["updateProdCache()"]
updateProdCache --> getProdABIs["getProdContractABIs()"]
updateProdCache --> getLastMod["getLastModified()"]
updateProdCache --> writeCache["Write Cache File"]
end

subgraph Development Flow
procDev --> updateDevCache["updateDevCache()"]
updateDevCache --> getDevABIs["getDevContractABIs()"]
updateDevCache --> getLastMod
updateDevCache --> writeCache
end

subgraph File Generation
genIndex --> |"Generate"| indexTS["dist/index.ts"]
writeCache --> |"Generate"| prodTS["dist/prod/*.ts"]
writeCache --> |"Generate"| devTS["dist/dev/*.ts"]
end

subgraph Configuration
config["Constants & Config"]
networks["Network Definitions"]
contractMap["Contract Name Mappings"]
config --> main
networks --> main
contractMap --> updateProdCache
contractMap --> updateDevCache
end

subgraph GitHub API
getProdABIs --> |"Fetch"| ghAPI["GitHub API"]
getDevABIs --> |"Fetch"| ghAPI
getLastMod --> |"Fetch"| ghAPI
end

style main fill:#f9f,stroke:#333,stroke-width:4px
style ghAPI fill:#b8d4ff,stroke:#333
style config fill:#d4ffb8,stroke:#333
```

eg.
## Project Structure

```
LIT_ABI_SOURCE=prod GH_LIT_ASSETS_READ_ONLY_API=xxx bun run fetch-contracts.ts

// for specific branch
DEV_BRANCH=develop LIT_ABI_SOURCE=prod GH_LIT_ASSETS_READ_ONLY_API=xxx bun run fetch-contracts.ts
src/
├── config/ # Configuration constants and network definitions
├── services/ # Core business logic services
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
└── index.ts # Main entry point
```

# To trigger build
## Prerequisites

```
curl -X POST -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token github_pat_<____YOUR_GITHUB_PERSONAL_ACCESS_TOKEN____>" \
https://api.github.com/repos/LIT-Protocol/lit-contracts/dispatches \
-d '{"event_type":"sync_trigger"}'
```
- Node.js 16 or higher
- GitHub Personal Access Token with read permissions

# Installation
## Environment Variables

```
- `GH_API_KEY`: GitHub Personal Access Token (required)
- `DEV_BRANCH`: Development branch name (defaults to 'develop')

## Installation

```bash
yarn add @lit-protocol/contracts
```

# Usage
## Usage

## for "main" branch
### Production Networks (from 'networks' repo)

### Production (Getting data from `networks` repo )

```
```typescript
import { datilDev, datilTest, datil } from "@lit-protocol/contracts";

console.log("datilDev:", datilDev);
console.log("datilTest:", datilTest);
console.log("datil:", datil);
```

### Development (Getting data from `lit-assets` repo `develop` branch )
### Development Networks (from 'lit-assets' repo)

```
import { _datilDev, _datilTest, _datil } from "@lit-protocol/contracts";
```typescript
import { develop } from "@lit-protocol/contracts";

console.log("datilDev:", _datilDev);
console.log("datilTest:", _datilTest);
console.log("datil:", _datil);
console.log("Development contracts:", develop);
```

## for any other branches with `dev-` prefix
## Local Development

### Development (Getting data from `lit-assets` repo with whatever the branch name is)
1. Clone the repository
2. Install dependencies:
```bash
yarn install
```
3. Set up environment variables:
```bash
export GH_API_KEY=your_github_token
export LIT_ABI_SOURCE=prod # or 'dev'
```
4. Run the fetcher:

eg. if your branch here is called `dev-datil` then it will pull data from lit-assets `datil` branch
```bash
# For default branch
bun run fetch-contracts.ts

the `dev-` prefix is to allow GitHub action to publish to npm.
# For specific branch
DEV_BRANCH=develop bun run fetch-contracts.ts
```

```
import { _datilDev, _datilTest, _datil } from "@lit-protocol/contracts";
## CI/CD Workflow

console.log("datilDev:", _datilDev);
console.log("datilTest:", _datilTest);
console.log("datil:", _datil);
```

# Branching & dev strategy

![](https://i.ibb.co/Z136p20/image.png)
![](https://www.plantuml.com/plantuml/png/TP6nSl8m48HxFSMLvf-11p35Ju0KAI0COM1I2ljiYyWdpKaYuUqZ2Po9YtIQtTMdqzx2USa-z5haWoWFhDeM6Kw6FnfjFkT2DL0Cwk5cyVy4V8S4nIwuRY9GEuHYZzOuvGtVOAsSbRvA5jMg4UKRUdYcgs93FPA7esGbpnhTdRraILKtHc-aeea0o7SRmv04k2Vd-SbqiyRhzDyejiRhA0N5QmJoA9EL8VLhnc1XQsgSNHn8gc4PQ2xA5ugzQ1t1DYQHAfN6BlU1eC7uoMbboBEil9jv1vPD_RSRntsOBHAoz3Z5BsiuklqbKLUcxvNFhwTkOTL9QeUQTk6iLHIVTDmArZzLlQFBtrk6ti8HsIaJ1mSOQ0y9af_r0UGDR7UReQUjoPIqF2rlS99CYjgX7-UD5Oju3ht-1W00)

# CI Workflow
## License

![](https://www.plantuml.com/plantuml/png/TP6nSl8m48HxFSMLvf-11p35Ju0KAI0COM1I2ljiYyWdpKaYuUqZ2Po9YtIQtTMdqzx2USa-z5haWoWFhDeM6Kw6FnfjFkT2DL0Cwk5cyVy4V8S4nIwuRY9GEuHYZzOuvGtVOAsSbRvA5jMg4UKRUdYcgs93FPA7esGbpnhTdRraILKtHc-aeea0o7SRmv04k2Vd-SbqiyRhzDyejiRhA0N5QmJoA9EL8VLhnc1XQsgSNHn8gc4PQ2xA5ugzQ1t1DYQHAfN6BlU1eC7uoMbboBEil9jv1vPD_RSRntsOBHAoz3Z5BsiuklqbKLUcxvNFhwTkOTL9QeUQTk6iLHIVTDmArZzLlQFBtrk6ti8HsIaJ1mSOQ0y9af_r0UGDR7UReQUjoPIqF2rlS99CYjgX7-UD5Oju3ht-1W00)
MIT
Binary file modified bun.lockb
Binary file not shown.
Loading