Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.1.0-21 (2025-02-15)

This was a version bump only, there were no code changes.

## 0.1.0-20 (2025-02-15)

This was a version bump only, there were no code changes.

## 0.1.0-19 (2025-02-05)

This was a version bump only, there were no code changes.
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ In addition to the documentation here, please visit [here](https://developer.lit
- [Features](#features)
- [Key Definitions](#key-definitions)
- [Architecture](#architecture)
- [Creating a New Tool](#creating-a-new-tool)
- [Creating a New Tool](#creating-a-new-tool-package)
- [Getting Started](#getting-started)
- [CLI Demo](#cli-users)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Addtional Support](#additional-support)

## Introduction

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"clean": "node tools/clean.js",
"lint": "npx nx run-many -t lint",
"test": "npx nx run-many -t test -- --passWithNoTests",
"deploy:tools": "npx nx deploy aw-tool-uniswap-swap && npx nx deploy aw-tool-sign-ecdsa && npx nx deploy aw-tool-erc20-transfer && npx nx deploy aw-tool-enso",
"deploy:tools": "npx nx deploy aw-tool-uniswap-swap && npx nx deploy aw-tool-sign-ecdsa && npx nx deploy aw-tool-erc20-transfer && npx nx deploy aw-tool-sign-eddsa && npx nx deploy aw-tool-jupiter-swap && npx nx deploy aw-tool-enso",
"start:cli": "pnpm build && pnpm deploy:tools && NO_DEPRECATION=* node packages/law-cli/dist/src/index.js",
"start:cli:no-build": "NO_DEPRECATION=* node packages/law-cli/dist/src/index.js",
"docs": "npx typedoc --options typedoc.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/agent-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@lit-protocol/agent-wallet",
"version": "0.1.0-19",
"version": "0.1.0-21",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@lit-protocol/constants": "7.0.2",
"@lit-protocol/constants": "7.0.6",
"@lit-protocol/aw-subagent-openai": "workspace:*",
"@lit-protocol/aw-signer": "workspace:*",
"@lit-protocol/aw-tool": "workspace:*",
Expand Down
11 changes: 10 additions & 1 deletion packages/agent-wallet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@
{
"path": "../aw-tool-uniswap-swap"
},
{
"path": "../aw-tool-sign-eddsa"
},
{
"path": "../aw-tool-sign-ecdsa"
},
{
"path": "../aw-tool-jupiter-swap"
},
{
"path": "../aw-tool-erc20-transfer"
},
{
"path": "../aw-tool-enso"
},
{
"path": "../aw-tool"
},
{
"path": "../aw-tool-registry"
},
{
"path": "../aw-tool"
"path": "../aw-contracts-sdk"
},
{
"path": "../aw-signer"
Expand Down
11 changes: 10 additions & 1 deletion packages/agent-wallet/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,29 @@
{
"path": "../aw-tool-uniswap-swap/tsconfig.lib.json"
},
{
"path": "../aw-tool-sign-eddsa/tsconfig.lib.json"
},
{
"path": "../aw-tool-sign-ecdsa/tsconfig.lib.json"
},
{
"path": "../aw-tool-jupiter-swap/tsconfig.lib.json"
},
{
"path": "../aw-tool-erc20-transfer/tsconfig.lib.json"
},
{
"path": "../aw-tool-enso/tsconfig.lib.json"
},
{
"path": "../aw-tool/tsconfig.lib.json"
},
{
"path": "../aw-tool-registry/tsconfig.lib.json"
},
{
"path": "../aw-tool/tsconfig.lib.json"
"path": "../aw-contracts-sdk/tsconfig.lib.json"
},
{
"path": "../aw-signer/tsconfig.lib.json"
Expand Down
9 changes: 9 additions & 0 deletions packages/aw-contracts-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# aw-contracts-sdk

This package contains the contracts and some utility functions for interacting with the `PkpToolRegistry` contracts.

The Ethers.js human-readable ABI is located in [`src/lib/human-readable-abi.ts`](src/lib/human-readable-abi.ts), and can be imported from this package as `PKP_TOOL_REGISTRY_ABI`.

You can also import `getPkpToolRegistryContract` function and call it to get an ether.js contract instance of `PkpToolRegistry`.

`DEFAULT_REGISTRY_CONFIG` is also exported and contains the `PkpToolRegistry` contract addresses for the different Lit networks.
19 changes: 19 additions & 0 deletions packages/aw-contracts-sdk/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const baseConfig = require('../../eslint.config.cjs');

module.exports = [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
},
],
},
languageOptions: {
parser: require('jsonc-eslint-parser'),
},
},
];
10 changes: 10 additions & 0 deletions packages/aw-contracts-sdk/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
displayName: 'aw-contracts-sdk',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: 'test-output/jest/coverage',
};
26 changes: 26 additions & 0 deletions packages/aw-contracts-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@lit-protocol/aw-contracts-sdk",
"version": "0.1.0-21",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@lit-protocol/aw-tool-registry": "workspace:*",
"@lit-protocol/aw-tool": "workspace:*",
"@lit-protocol/constants": "7.0.6",
"ethers": "v5",
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"files": [
"dist",
"!**/*.tsbuildinfo"
],
"nx": {
"sourceRoot": "packages/aw-contracts-sdk/src",
"projectType": "library",
"name": "aw-contracts-sdk"
}
}
4 changes: 4 additions & 0 deletions packages/aw-contracts-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './lib/pkp-tool-registry-contract';
export * from './lib/human-readable-abi';
export * from './lib/get-registered-tools-and-delegatees';
export * from './lib/get-permitted-tools-for-delegatee';
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const processKnownTool = (
name: registryTool.tool.name,
description: registryTool.tool.description,
ipfsCid: registryTool.tool.ipfsCid,
chain: registryTool.tool.chain,
parameters: registryTool.tool.parameters,
policy: registryTool.tool.policy,
network: registryTool.network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
ToolInfo,
RegisteredToolsResult,
RegistryToolResult,
} from '../../types';
} from './types';

/**
* Process delegatee policies for a tool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
import { LIT_RPC } from '@lit-protocol/constants';
import { ethers } from 'ethers';

import { ToolRegistryConfig } from '../../types';

export const DEFAULT_REGISTRY_CONFIG: Record<string, ToolRegistryConfig> = {
'datil-dev': {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0x2707eabb60D262024F8738455811a338B0ECd3EC',
},
'datil-test': {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0x525bF2bEb622D7C05E979a8b3fFcDBBEF944450E',
},
datil: {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0xBDEd44A02b64416C831A0D82a630488A854ab4b1',
},
} as const;

const PKP_TOOL_REGISTRY_ABI = [
export const PKP_TOOL_REGISTRY_ABI = [
// Tool Facet Functions
'function registerTools(uint256 pkpTokenId, string[] calldata toolIpfsCids, bool enabled) external',
'function removeTools(uint256 pkpTokenId, string[] calldata toolIpfsCids) external',
Expand Down Expand Up @@ -94,17 +74,3 @@ const PKP_TOOL_REGISTRY_ABI = [
'event PolicyParametersRemoved(uint256 indexed pkpTokenId, string toolIpfsCids, address delegatee, string[] parameterNames)',
'event ToolsUnpermitted(uint256 indexed pkpTokenId, string[] toolIpfsCids, address[] delegatees)',
];

export const getPkpToolRegistryContract = (
{ rpcUrl, contractAddress }: ToolRegistryConfig,
signer: ethers.Signer
) => {
const contract = new ethers.Contract(
contractAddress,
PKP_TOOL_REGISTRY_ABI,
new ethers.providers.JsonRpcProvider(rpcUrl)
);

// Connect the signer to allow write operations
return contract.connect(signer);
};
51 changes: 51 additions & 0 deletions packages/aw-contracts-sdk/src/lib/pkp-tool-registry-contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { LIT_RPC } from '@lit-protocol/constants';
import { ethers } from 'ethers';

import { PKP_TOOL_REGISTRY_ABI } from './human-readable-abi';

/**
* Configuration for the Tool Policy Registry contract.
* Includes the RPC URL and contract address for interacting with the registry.
*/
export interface ToolRegistryConfig {
/** The RPC URL for the blockchain network. */
rpcUrl: string;

/** The address of the Tool Policy Registry contract. */
contractAddress: string;
}

export const DEFAULT_REGISTRY_CONFIG: Record<string, ToolRegistryConfig> = {
'datil-dev': {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0x2707eabb60D262024F8738455811a338B0ECd3EC',
},
'datil-test': {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0x525bF2bEb622D7C05E979a8b3fFcDBBEF944450E',
},
datil: {
rpcUrl: LIT_RPC.CHRONICLE_YELLOWSTONE,
contractAddress: '0xBDEd44A02b64416C831A0D82a630488A854ab4b1',
},
} as const;

/**
* Creates a new instance of the PKP Tool Registry contract.
* @param config - The configuration for the Tool Policy Registry contract, includes the RPC URL and contract address.
* @param signer - An optional ethers.Signer instance for write operations.
* @returns A new instance of the PKP Tool Registry contract.
*/
export const getPkpToolRegistryContract = (
{ rpcUrl, contractAddress }: ToolRegistryConfig,
signer?: ethers.Signer
) => {
const contract = new ethers.Contract(
contractAddress,
PKP_TOOL_REGISTRY_ABI,
new ethers.providers.JsonRpcProvider(rpcUrl)
);

// Connect the signer to allow write operations
return signer ? contract.connect(signer) : contract;
};
53 changes: 53 additions & 0 deletions packages/aw-contracts-sdk/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { type LitNetwork } from '@lit-protocol/aw-tool-registry';
import type { AwTool } from '@lit-protocol/aw-tool';

export type ToolInfo = {
toolIpfsCid: string;
toolEnabled: boolean;
delegatees: string[];
delegateesPolicyIpfsCids: string[];
delegateesPolicyEnabled: boolean[];
};

export type RegistryToolResult = {
tool: AwTool<any, any>;
network: LitNetwork;
} | null;

export type ToolMetadata = NonNullable<RegistryToolResult>['tool'] & {
network: NonNullable<RegistryToolResult>['network'];
toolEnabled?: boolean;
delegatees: string[];
};

export type RegisteredToolWithPolicies = ToolMetadata & {
delegatees: string[];
delegateePolicies: {
[delegatee: string]: {
policyIpfsCid: string;
policyEnabled: boolean;
};
};
};

export type RegisteredToolsResult = {
toolsWithPolicies: {
[ipfsCid: string]: RegisteredToolWithPolicies;
};
toolsWithoutPolicies: {
[ipfsCid: string]: ToolMetadata;
};
toolsUnknownWithPolicies: {
[ipfsCid: string]: {
toolEnabled: boolean;
delegatees: string[];
delegateePolicies: {
[delegatee: string]: {
policyIpfsCid: string;
policyEnabled: boolean;
};
};
};
};
toolsUnknownWithoutPolicies: string[];
};
37 changes: 37 additions & 0 deletions packages/aw-contracts-sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "../aw-tool-uniswap-swap"
},
{
"path": "../aw-tool-sign-eddsa"
},
{
"path": "../aw-tool-sign-ecdsa"
},
{
"path": "../aw-tool-jupiter-swap"
},
{
"path": "../aw-tool-erc20-transfer"
},
{
"path": "../aw-tool-enso"
},
{
"path": "../aw-tool"
},
{
"path": "../aw-tool-registry"
},
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
Loading
Loading