Skip to content

Commit

Permalink
Further implementing nx
Browse files Browse the repository at this point in the history
  • Loading branch information
spacesailor24 committed Dec 21, 2024
1 parent 4caea02 commit 4a6156f
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 92 deletions.
104 changes: 15 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,26 @@
# Commands

- Deploy `PKPTools.sol` using existing Safe contract:

```bash
SAFE_ADDRESS=0x... forge script script/PKPTools.s.sol --rpc-url <your-rpc-url> --private-key <your-private-key>
```

- Deploy `PKPTools.sol` using new Safe contract:
# Using Nx

```bash
forge script script/PKPTools.s.sol --rpc-url <your-rpc-url> --private-key <your-private-key>
```
# Build a specific project
nx build lit-agent-contracts

- Deploy `LitAgentRegistry.sol`:

```bash
# Terminal 1: Start Anvil
anvil
# Test a specific project
nx test lit-agent-contracts

# Terminal 2: Deploy the contract
# First time setup
cp .env.example .env # Create .env file from example
vim .env # Edit to add private key from Anvil output
# Run a command on all projects
nx run-many --target=build --all

# Deploy
source .env
forge script script/DeployLitAgentRegistry.s.sol:DeployLitAgentRegistry --rpc-url http://localhost:8545 --broadcast
# Run a command on affected projects only
nx affected --target=build
```

# Adding Uniswap Tool

```bash
1000000000000000000

0x4200000000000000000000000000000000000006,0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf
```

# Prompts

```
Swap .00001 WETH (0x4200000000000000000000000000000000000006) to Coinbase Wrapped BTC (0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf)
```
# View dependency graph
nx graph

# Lit Agent Registry Deployment
# See what projects are affected by your changes
nx affected:graph

```json
{
"transactions": [
{
"hash": "0x39fd6d38879c27f641d4853b8e31ddec3f147852f0f768c0dbba3779c8cc52b9",
"transactionType": "CREATE",
"contractName": "LitAgentRegistry",
"contractAddress": "0x728e8162603f35446d09961c4a285e2643f4fb91",
"function": null,
"arguments": null,
"transaction": {
"from": "0xa89543a7145c68e52a4d584f1ceb123605131211",
"gas": "0x15b649",
"value": "0x0",
"input": "0x608060405234801561000f575f80fd5b506112d08061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610060575f3560e01c806311c10486146100645780631a58ec83146100795780632f3bd0d2146100a457806331ab5c38146100b75780636f4e9ab1146100f1578063f91408e114610104575b5f80fd5b610077610072366004610bd8565b610126565b005b61008c610087366004610c7b565b6102bd565b60405161009b93929190610d25565b60405180910390f35b6100776100b2366004610d5b565b610488565b6100e16100c5366004610daa565b5f60208181529281526040808220909352908152205460ff1681565b604051901515815260200161009b565b6100776100ff366004610ddb565b6106b3565b610117610112366004610daa565b610773565b60405161009b93929190610e53565b335f908152602081815260408083206001600160a01b038b16845290915290205460ff1661016f5760405162461bcd60e51b815260040161016690610ed3565b60405180910390fd5b826101bc5760405162461bcd60e51b815260206004820152601760248201527f4465736372697074696f6e2069732072657175697265640000000000000000006044820152606401610166565b335f908152602081815260408083206001600160a01b038b168452909152808220905190919060018301906101f4908a908a90610eff565b908152604051908190036020019020805490915060ff16610232576002820180546001810182555f918252602090912001610230888a83610fa6565b505b805460ff191660019081178255810161024c868883610fa6565b506002810161025c848683610fa6565b50886001600160a01b0316336001600160a01b03167f23b33d63e2dd018917dc352f3714de342280694a99f26e74af4bdc428d10d7958a8a8a8a8a8a6040516102aa96959493929190611088565b60405180910390a3505050505050505050565b6001600160a01b038085165f90815260208181526040808320938716835292905290812054606090819060ff166103065760405162461bcd60e51b815260040161016690610ed3565b6001600160a01b038088165f90815260208181526040808320938a168352929052818120915190916001019061033f9088908890610eff565b908152604051908190036020019020805460018201805492935060ff909116916002840190829061036f90610f22565b80601f016020809104026020016040519081016040528092919081815260200182805461039b90610f22565b80156103e65780601f106103bd576101008083540402835291602001916103e6565b820191905f5260205f20905b8154815290600101906020018083116103c957829003601f168201915b505050505091508080546103f990610f22565b80601f016020809104026020016040519081016040528092919081815260200182805461042590610f22565b80156104705780601f1061044757610100808354040283529160200191610470565b820191905f5260205f20905b81548152906001019060200180831161045357829003601f168201915b50505050509050935093509350509450945094915050565b335f908152602081815260408083206001600160a01b038716845290915290205460ff166104c85760405162461bcd60e51b815260040161016690610ed3565b335f908152602081815260408083206001600160a01b038716845290915290819020905160018201906104fe9085908590610eff565b908152604051908190036020018120805460ff1916905560018201906105279085908590610eff565b90815260200160405180910390206001015f6105439190610b26565b806001018383604051610557929190610eff565b90815260200160405180910390206002015f6105739190610b26565b5f5b600282015481101561065f578383604051610591929190610eff565b60405180910390208260020182815481106105ae576105ae6110d0565b905f5260205f20016040516105c391906110e4565b604051809103902003610657576002820180546105e290600190611156565b815481106105f2576105f26110d0565b905f5260205f200182600201828154811061060f5761060f6110d0565b905f5260205f20019081610623919061117b565b508160020180548061063757610637611250565b600190038181905f5260205f20015f6106509190610b26565b905561065f565b600101610575565b50836001600160a01b0316336001600160a01b03167ff7aacca5f8ccd631a41c2b17a7dbedc53684f6a3d7a54816ae52214ea8d3168785856040516106a5929190611264565b60405180910390a350505050565b335f908152602081815260408083206001600160a01b038516845290915290205460ff161561071d5760405162461bcd60e51b81526020600482015260166024820152751412d408185b1c9958591e481c9959da5cdd195c995960521b6044820152606401610166565b335f818152602081815260408083206001600160a01b0386168085529252808320805460ff19166001179055519092917f420995fedd4979c1c4285377b4037cd2a8f7d91d4907a9f8847bfefcdcf8889a91a350565b6001600160a01b038083165f90815260208181526040808320938516835292905220546060908190819060ff166107bc5760405162461bcd60e51b815260040161016690610ed3565b6001600160a01b038086165f9081526020818152604080832093881683529290522060028101548067ffffffffffffffff8111156107fc576107fc610f0e565b60405190808252806020026020018201604052801561082f57816020015b606081526020019060019003908161081a5790505b5094508067ffffffffffffffff81111561084b5761084b610f0e565b60405190808252806020026020018201604052801561087e57816020015b60608152602001906001900390816108695790505b5093508067ffffffffffffffff81111561089a5761089a610f0e565b6040519080825280602002602001820160405280156108cd57816020015b60608152602001906001900390816108b85790505b5092505f5b81811015610b1c575f8360020182815481106108f0576108f06110d0565b905f5260205f2001805461090390610f22565b80601f016020809104026020016040519081016040528092919081815260200182805461092f90610f22565b801561097a5780601f106109515761010080835404028352916020019161097a565b820191905f5260205f20905b81548152906001019060200180831161095d57829003601f168201915b505050505090505f8460010182604051610994919061127f565b90815260200160405180910390209050818884815181106109b7576109b76110d0565b60200260200101819052508060010180546109d190610f22565b80601f01602080910402602001604051908101604052809291908181526020018280546109fd90610f22565b8015610a485780601f10610a1f57610100808354040283529160200191610a48565b820191905f5260205f20905b815481529060010190602001808311610a2b57829003601f168201915b5050505050878481518110610a5f57610a5f6110d0565b6020026020010181905250806002018054610a7990610f22565b80601f0160208091040260200160405190810160405280929190818152602001828054610aa590610f22565b8015610af05780601f10610ac757610100808354040283529160200191610af0565b820191905f5260205f20905b815481529060010190602001808311610ad357829003601f168201915b5050505050868481518110610b0757610b076110d0565b602090810291909101015250506001016108d2565b5050509250925092565b508054610b3290610f22565b5f825580601f10610b41575050565b601f0160209004905f5260205f2090810190610b5d9190610b60565b50565b5b80821115610b74575f8155600101610b61565b5090565b80356001600160a01b0381168114610b8e575f80fd5b919050565b5f8083601f840112610ba3575f80fd5b50813567ffffffffffffffff811115610bba575f80fd5b602083019150836020828501011115610bd1575f80fd5b9250929050565b5f805f805f805f6080888a031215610bee575f80fd5b610bf788610b78565b9650602088013567ffffffffffffffff80821115610c13575f80fd5b610c1f8b838c01610b93565b909850965060408a0135915080821115610c37575f80fd5b610c438b838c01610b93565b909650945060608a0135915080821115610c5b575f80fd5b50610c688a828b01610b93565b989b979a50959850939692959293505050565b5f805f8060608587031215610c8e575f80fd5b610c9785610b78565b9350610ca560208601610b78565b9250604085013567ffffffffffffffff811115610cc0575f80fd5b610ccc87828801610b93565b95989497509550505050565b5f5b83811015610cf2578181015183820152602001610cda565b50505f910152565b5f8151808452610d11816020860160208601610cd8565b601f01601f19169290920160200192915050565b8315158152606060208201525f610d3f6060830185610cfa565b8281036040840152610d518185610cfa565b9695505050505050565b5f805f60408486031215610d6d575f80fd5b610d7684610b78565b9250602084013567ffffffffffffffff811115610d91575f80fd5b610d9d86828701610b93565b9497909650939450505050565b5f8060408385031215610dbb575f80fd5b610dc483610b78565b9150610dd260208401610b78565b90509250929050565b5f60208284031215610deb575f80fd5b610df482610b78565b9392505050565b5f8282518085526020808601955060208260051b840101602086015f5b84811015610e4657601f19868403018952610e34838351610cfa565b98840198925090830190600101610e18565b5090979650505050505050565b5f606082016060835280865180835260808501915060808160051b860101925060208089015f5b83811015610ea857607f19888703018552610e96868351610cfa565b95509382019390820190600101610e7a565b50505050508281036020840152610ebf8186610dfb565b90508281036040840152610d518185610dfb565b6020808252601290820152711412d4081b9bdd081c9959da5cdd195c995960721b604082015260600190565b818382375f9101908152919050565b634e487b7160e01b5f52604160045260245ffd5b600181811c90821680610f3657607f821691505b602082108103610f5457634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115610fa157805f5260205f20601f840160051c81016020851015610f7f5750805b601f840160051c820191505b81811015610f9e575f8155600101610f8b565b50505b505050565b67ffffffffffffffff831115610fbe57610fbe610f0e565b610fd283610fcc8354610f22565b83610f5a565b5f601f841160018114611003575f8515610fec5750838201355b5f19600387901b1c1916600186901b178355610f9e565b5f83815260208120601f198716915b828110156110325786850135825560209485019460019092019101611012565b508682101561104e575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b606081525f61109b60608301888a611060565b82810360208401526110ae818789611060565b905082810360408401526110c3818587611060565b9998505050505050505050565b634e487b7160e01b5f52603260045260245ffd5b5f8083546110f181610f22565b60018281168015611109576001811461111e5761114a565b60ff198416875282151583028701945061114a565b875f526020805f205f5b858110156111415781548a820152908401908201611128565b50505082870194505b50929695505050505050565b8181038181111561117557634e487b7160e01b5f52601160045260245ffd5b92915050565b818103611186575050565b6111908254610f22565b67ffffffffffffffff8111156111a8576111a8610f0e565b6111bc816111b68454610f22565b84610f5a565b5f601f8211600181146111ed575f83156111d65750848201545b5f19600385901b1c1916600184901b178455610f9e565b5f8581526020808220868352908220601f198616925b838110156112235782860154825560019586019590910190602001611203565b508583101561124057818501545f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52603160045260245ffd5b602081525f611277602083018486611060565b949350505050565b5f8251611290818460208701610cd8565b919091019291505056fea2646970667358221220242d9bc72b7cf648c98044bc859bc552c862f2ee559401e47285b340819d68a464736f6c63430008180033",
"nonce": "0x9",
"chainId": "0x2105"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x19ffa44",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0x39fd6d38879c27f641d4853b8e31ddec3f147852f0f768c0dbba3779c8cc52b9",
"transactionIndex": "0x9c",
"blockHash": "0x713a48391188e5f67675ca479de627ae1f0234e384e9e9f482ae1995e94b1984",
"blockNumber": "0x16cf3ec",
"gasUsed": "0x10b39b",
"effectiveGasPrice": "0x1c1ae9c",
"from": "0xa89543a7145c68e52a4d584f1ceb123605131211",
"to": null,
"contractAddress": "0x728e8162603f35446d09961c4a285e2643f4fb91",
"l1BaseFeeScalar": "0x8dd",
"l1BlobBaseFee": "0x3f5694c1f",
"l1BlobBaseFeeScalar": "0x101c12",
"l1Fee": "0x2f4d94583335",
"l1GasPrice": "0x5ac836983",
"l1GasUsed": "0xac95"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1734624444,
"chain": 8453,
"commit": "59f5750"
}
# Run multiple tasks
nx run-many --target=build,test,lint
```
12 changes: 12 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const nxPreset = require("@nx/jest/preset").default;

module.exports = {
...nxPreset,
testMatch: ["**/+(*.)+(spec|test).+(ts|js)?(x)"],
transform: {
"^.+\\.(ts|js|html)$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.json" }],
},
resolver: "@nx/jest/plugins/resolver",
moduleFileExtensions: ["ts", "js", "html"],
coverageReporters: ["html", "lcov", "json", "text"],
};
24 changes: 22 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"defaultBase": "main"
}
"defaultBase": "main",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "test", "lint"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"cache": true
},
"test": {
"cache": true
},
"lint": {
"cache": true
}
}
}
33 changes: 33 additions & 0 deletions packages/lit-agent-cli/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lit-agent-cli",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-cli/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/lit-agent-cli",
"main": "packages/lit-agent-cli/src/index.ts",
"tsConfig": "packages/lit-agent-cli/tsconfig.json",
"assets": ["packages/lit-agent-cli/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/lit-agent-cli/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/lit-agent-cli/jest.config.ts"
}
}
},
"tags": []
}
23 changes: 23 additions & 0 deletions packages/lit-agent-contracts/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "lit-agent-contracts",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-contracts",
"projectType": "library",
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"command": "forge build",
"cwd": "packages/lit-agent-contracts"
}
},
"test": {
"executor": "nx:run-commands",
"options": {
"command": "forge test",
"cwd": "packages/lit-agent-contracts"
}
}
},
"tags": []
}
33 changes: 33 additions & 0 deletions packages/lit-agent-tool-send-erc20/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lit-agent-tool-send-erc20",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-tool-send-erc20/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/lit-agent-tool-send-erc20",
"main": "packages/lit-agent-tool-send-erc20/src/index.ts",
"tsConfig": "packages/lit-agent-tool-send-erc20/tsconfig.json",
"assets": ["packages/lit-agent-tool-send-erc20/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/lit-agent-tool-send-erc20/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/lit-agent-tool-send-erc20/jest.config.ts"
}
}
},
"tags": []
}
33 changes: 33 additions & 0 deletions packages/lit-agent-tool-signer/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lit-agent-tool-signer",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-tool-signer/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/lit-agent-tool-signer",
"main": "packages/lit-agent-tool-signer/src/index.ts",
"tsConfig": "packages/lit-agent-tool-signer/tsconfig.json",
"assets": ["packages/lit-agent-tool-signer/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/lit-agent-tool-signer/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/lit-agent-tool-signer/jest.config.ts"
}
}
},
"tags": []
}
33 changes: 33 additions & 0 deletions packages/lit-agent-tool-uniswap/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lit-agent-tool-uniswap",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-tool-uniswap/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/lit-agent-tool-uniswap",
"main": "packages/lit-agent-tool-uniswap/src/index.ts",
"tsConfig": "packages/lit-agent-tool-uniswap/tsconfig.json",
"assets": ["packages/lit-agent-tool-uniswap/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/lit-agent-tool-uniswap/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/lit-agent-tool-uniswap/jest.config.ts"
}
}
},
"tags": []
}
33 changes: 33 additions & 0 deletions packages/lit-agent-toolkit/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "lit-agent-toolkit",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/lit-agent-toolkit/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/lit-agent-toolkit",
"main": "packages/lit-agent-toolkit/src/index.ts",
"tsConfig": "packages/lit-agent-toolkit/tsconfig.json",
"assets": ["packages/lit-agent-toolkit/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/lit-agent-toolkit/**/*.ts"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/lit-agent-toolkit/jest.config.ts"
}
}
},
"tags": []
}
Loading

0 comments on commit 4a6156f

Please sign in to comment.