Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/tidy-masks-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-protocol/contracts': patch
---

This is the first monorepo release and should behave exactly like v0.5.1. If anything breaks, roll back to v0.5.1.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ lit-auth-local
artillery-state.json
artillery-pkp-tokens
lit-auth-artillery
alice-auth-manager-data
alice-auth-manager-data

!/packages/contracts/dist/
!/packages/contracts/dist/dev
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ git commit -m "chore: release v0.0.1"
bunx changeset publish
```

## Keeping the contract address and ABIs in sync with the latest changes

This command must be run manually and is NOT part of the build process, as it requires a GitHub API key.

```
DEV_BRANCH=develop GH_API_KEY=github_pat_xxx bun run sync:contracts
```

---

# Legacy Documentation for V7 and Earlier
Expand Down
311 changes: 275 additions & 36 deletions bun.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"license": "MIT",
"scripts": {
"reset": "bun unlink-all && rimraf dist node_modules doc tmp yarn-error.log yarn.lock package-lock.json bun.lockb learn-debug.log tmp .nx lit-auth-storage pkp-tokens lit-auth-local ./e2e/dist ./e2e/node_modules",
"go": "bun run build && bun link-all",
"build": "bun unlink-all && nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions && bun run prettier",
"build:affected": "nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions",
"build": "nx run-many --parallel=false --target=build --all --exclude=wrapped-keys,wrapped-keys-lit-actions,contracts && bun run prettier",
"build:affected": "nx affected --target=build --exclude=wrapped-keys,wrapped-keys-lit-actions,contracts",
"check-deps": "npx nx run-many --target=check-deps --exclude=wrapped-keys,wrapped-keys-lit-actions",
"validate": "npm run check-deps && npm run build",
"test:local": "node ./local-tests/build.mjs && dotenvx run --env-file=.env -- node ./local-tests/build/test.mjs",
Expand All @@ -18,6 +17,7 @@
"gen:docs": "node ./tools/scripts/gen-doc.mjs",
"gen:readme": "node ./tools/scripts/gen-readme.mjs",
"gen:local-network-context": "bun run packages/networks/src/networks/vNaga/envs/naga-local/scripts/00-generate-abi-signatures.ts",
"sync:contracts": "nx run contracts:sync",
"prettier": "npx nx format:write --all",
"lint": "npx nx run-many --target=lint --all",
"lint:fix": "npx nx run-many --target=lint --all -- --fix",
Expand All @@ -37,7 +37,6 @@
"private": true,
"dependencies": {
"@dotenvx/dotenvx": "^1.6.4",
"@lit-protocol/contracts": "0.5.1",
"@lit-protocol/nacl": "7.1.1",
"@lit-protocol/uint8arrays": "7.1.1",
"@metamask/eth-sig-util": "5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@elysiajs/cors": "^1.2.0",
"@elysiajs/static": "^1.3.0",
"@elysiajs/swagger": "^1.2.0",
"@lit-protocol/contracts": "^0.5.1",
"@lit-protocol/contracts": "workspace:*",
"@simplewebauthn/server": "6.2.1",
"@simplewebauthn/typescript-types": "^8.3.4",
"@t3-oss/env-core": "^0.12.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"type": "commonjs",
"dependencies": {
"@openagenda/verror": "^3.1.4",
"zod": "3.24.3"
"tslib": "^2.8.1",
"zod": "3.24.3",
"@lit-protocol/contracts": "workspace:*"
},
"publishConfig": {
"access": "public",
Expand Down
22 changes: 22 additions & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Configurations

All configs are in the `./src/config` directory

```bash
.
├── env.ts // 👈 to modify env vars
├── methods.ts // 👈 to add new ABI methods to extract
└── networks.ts // 👈 to add or modify a network
```

# Syncing Contract Addresses and ABIs

```shell
tsx ./src/sync.ts
```

or from monorepo root

```shell
nx run contracts:start
```
1 change: 1 addition & 0 deletions packages/contracts/dist/build.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
4 changes: 4 additions & 0 deletions packages/contracts/dist/config/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare const env: Readonly<{
GH_API_KEY: string;
DEV_BRANCH: string;
}>;
3 changes: 3 additions & 0 deletions packages/contracts/dist/config/methods.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare const METHODS_TO_EXTRACT: readonly ["PKPPermissions.getPermittedActions", "PKPPermissions.getPermittedAddresses", "PKPPermissions.isPermittedAction", "PKPPermissions.isPermittedAddress", "PKPPermissions.getPermittedAuthMethods", "PKPPermissions.getPermittedAuthMethodScopes", "PKPPermissions.addPermittedAction", "PKPPermissions.addPermittedAddress", "PKPPermissions.addPermittedAuthMethodScope", "PKPPermissions.addPermittedAuthMethod", "PKPPermissions.removePermittedAction", "PKPPermissions.removePermittedAddress", "PKPPermissions.removePermittedAuthMethod", "PKPPermissions.removePermittedAuthMethodScope", "PKPPermissions.getTokenIdsForAuthMethod", "PKPNFT.tokenOfOwnerByIndex", "PKPNFT.mintCost", "PKPNFT.safeTransferFrom", "PKPNFT.mintNext", "PKPNFT.claimAndMint", "PKPHelper.claimAndMintNextAndAddAuthMethodsWithTypes", "PKPHelper.mintNextAndAddAuthMethods", "Staking.getActiveUnkickedValidatorStructsAndCounts", "PriceFeed.getNodesForRequest", "PubkeyRouter.deriveEthAddressFromPubkey", "PubkeyRouter.ethAddressToPkpId", "PubkeyRouter.getPubkey", "PubkeyRouter.getEthAddress", "Ledger.deposit", "Ledger.depositForUser", "Ledger.balance", "Ledger.stableBalance", "Ledger.requestWithdraw", "Ledger.latestWithdrawRequest", "Ledger.userWithdrawDelay", "Ledger.withdraw", "PaymentDelegation.getPayersAndRestrictions", "PaymentDelegation.getUsers", "PaymentDelegation.getRestriction", "PaymentDelegation.getPayers", "PaymentDelegation.delegatePayments", "PaymentDelegation.undelegatePayments", "PaymentDelegation.delegatePaymentsBatch", "PaymentDelegation.undelegatePaymentsBatch", "PaymentDelegation.setRestriction"];
export type ContractName = 'PKPPermissions' | 'PKPNFT' | 'PKPHelper' | 'Staking' | 'PubkeyRouter';
export type ExtractMethodName<T extends string> = T extends `${ContractName}.${infer Method}` ? Method : never;
122 changes: 122 additions & 0 deletions packages/contracts/dist/config/networks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* Network Configuration
* Contains all network-related constants and configurations
*/
export declare const GITHUB_API_BASE = "https://api.github.com/repos";
export declare const USERNAME = "LIT-Protocol";
export declare const NETWORKS_REPO = "networks";
export declare const LIT_ASSETS_REPO = "lit-assets";
export declare const PROD_PATH_BY_NETWORK: {
readonly datil: "datil-prod";
readonly 'datil-dev': "datil-dev";
readonly 'datil-test': "datil-test";
readonly 'naga-dev': "naga-dev";
readonly 'naga-test': "naga-test";
readonly 'naga-staging': "naga-staging";
};
export declare const DEV_PATH_BY_NETWORK: {
readonly develop: "develop";
};
export type ProdNetworkName = keyof typeof PROD_PATH_BY_NETWORK;
export type DevNetworkName = keyof typeof DEV_PATH_BY_NETWORK;
export type NetworkName = ProdNetworkName | DevNetworkName;
export type NetworkPath = (typeof PROD_PATH_BY_NETWORK)[ProdNetworkName] | (typeof DEV_PATH_BY_NETWORK)[DevNetworkName];
/**
* Network path configuration for GitHub API requests
*
* Production:
* - Uses network-specific subdirectories (e.g., "datil-prod/abis" for datil network)
* - Special case: "datil" network uses "datil-prod" directory
*
* Development:
* - Uses a flat structure without network subdirectories
* - All files are in the same directory (e.g., "rust/lit-core/blockchain/abis")
*/
export declare const NETWORK_PATHS: {
readonly prod: {
/**
* Maps network names to their directory names
* Example: "datil" -> "datil-prod", "datil-dev" -> "datil-dev"
*/
readonly networkToPath: {
readonly datil: "datil-prod";
readonly 'datil-dev': "datil-dev";
readonly 'datil-test': "datil-test";
readonly 'naga-dev': "naga-dev";
readonly 'naga-test': "naga-test";
readonly 'naga-staging': "naga-staging";
};
/**
* Constructs the full path for production networks
* Format: <network-directory>/<content-path>
* Example: "datil-prod/abis"
*/
readonly getContentPath: (network: ProdNetworkName, contentPath: string) => string;
};
readonly dev: {
/**
* Maps network names to their directory names
* Example: "develop" -> "develop"
*/
readonly networkToPath: {
readonly develop: "develop";
};
/**
* Constructs the full path for development
* Uses the content path directly without network subdirectory
* Example: "rust/lit-core/blockchain/abis"
*/
readonly getContentPath: (network: DevNetworkName, contentPath: string) => string;
};
};
export declare const NETWORKS: {
readonly prod: {
readonly networks: ProdNetworkName[];
readonly deployedContracts: {
readonly 'datil-dev': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/datil-dev/deployed-lit-node-contracts-temp.json";
readonly 'datil-test': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/datil-test/deployed-lit-node-contracts-temp.json";
readonly datil: "https://raw.githubusercontent.com/LIT-Protocol/networks/main/datil-prod/deployed-lit-node-contracts-temp.json";
readonly 'naga-dev': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/naga-dev/deployed-lit-node-contracts-temp.json";
readonly 'naga-staging': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/naga-staging/deployed-lit-node-contracts-temp.json";
readonly 'naga-test': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/naga-test/deployed-lit-node-contracts-temp.json";
};
};
readonly dev: {
readonly networks: DevNetworkName[];
readonly deployedContracts: {
readonly develop: "https://raw.githubusercontent.com/LIT-Protocol/networks/main/naga-dev/deployed-lit-node-contracts-temp.json";
readonly 'datil-clone': "https://raw.githubusercontent.com/LIT-Protocol/networks/main/datil-clone/deployed-lit-node-contracts-temp.json";
};
};
};
export declare const CONTRACT_NAME_MAP: {
readonly litTokenContractAddress: "LITToken";
readonly pkpNftContractAddress: "PKPNFT";
readonly pkpHelperContractAddress: "PKPHelper";
readonly pkpPermissionsContractAddress: "PKPPermissions";
readonly pkpNftMetadataContractAddress: "PKPNFTMetadata";
readonly pubkeyRouterContractAddress: "PubkeyRouter";
readonly rateLimitNftContractAddress: "RateLimitNFT";
readonly stakingBalancesContractAddress: "StakingBalances";
readonly stakingContractAddress: "Staking";
readonly multisenderContractAddress: "Multisender";
readonly allowlistContractAddress: "Allowlist";
readonly paymentDelegationContractAddress: "PaymentDelegation";
readonly priceFeedContractAddress: "PriceFeed";
readonly cloneNetContractAddress: "CloneNet";
readonly ledgerContractAddress: "Ledger";
};
export declare const ENV_CONFIG: {
readonly prod: {
readonly repoName: "networks";
readonly path: "abis";
readonly fileExtensionToRemove: ".abi";
readonly abiSourceInJson: readonly [];
};
readonly dev: {
readonly repoName: "lit-assets";
readonly path: "rust/lit-core/lit-blockchain/abis";
readonly fileExtensionToRemove: ".json";
readonly abiSourceInJson: readonly ["abi"];
};
};
Loading
Loading