Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
zapaz committed Oct 27, 2024
2 parents 88f63df + 59242dc commit 9e4c813
Show file tree
Hide file tree
Showing 28 changed files with 1,298 additions and 1,182 deletions.
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "",
"description": "",
"dependencies": {
"@types/node": "^22.7.9",
"@types/node": "^22.8.1",
"eslint-plugin-json": "^4.0.1",
"ts-node": "^10.9.2",
"typescript": "^5.6.3"
Expand Down
8 changes: 4 additions & 4 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export PUBLIC_ALCHEMY_API_KEY=
export PUBLIC_WALLET_CONNECT_PROJECT_ID=
PUBLIC_ALCHEMY_API_KEY=
PUBLIC_WALLET_CONNECT_PROJECT_ID=
ETHERSCAN_API_KEY=
VERIFIER_URL="https://api.etherscan.io/api"

export ETHERSCAN_API_KEY_OPTIMISM=
export ETHERSCAN_API_KEY_BASE=
7 changes: 5 additions & 2 deletions foundry/addresses.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"11155420": {
"Counter": "0x8354Ef7b78012151c276f51F8d19147FF8C47288",
"OnChainAI": "0xd1ca741de2d2975822ADf4646Cf0A8AE3Df51c78",
"OnChainAIv1": "0x9ee2948E17b4C25434c7D0D252E71201A2D87B05",
"OnChainAIv1": "0x432beBA9B2Fc71180FF9ba3fA93E1Ae88beDF402",
"chainName": "optimism-sepolia"
},
"31337": {
"Counter": "0x9bAaB117304f7D6517048e371025dB8f89a8DbE5",
"OnChainAI": "0x31A65C6d4EB07ad51E7afc890aC3b7bE84dF2Ead",
"OnChainAIv1": "0x0116686E2291dbd5e317F47faDBFb43B599786Ef",
"chainName": "local"
Expand All @@ -15,8 +17,9 @@
"chainName": "base"
},
"84532": {
"Counter": "0x1bC96A82609F23419065FCEf120E16E2A6Bd3981",
"OnChainAI": "0xCB60F4a4e578CDDBe89e4a27B2126f54BaeF3500",
"OnChainAIv1": "0x93EB497b305D2cC4Fa3AC62009258EaE951043dB",
"OnChainAIv1": "0xBf196B3732880a51Eaa6Cfc38d82De1A61582B06",
"chainName": "base-sepolia"
}
}
8 changes: 0 additions & 8 deletions foundry/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ base = "https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
base-sepolia = "https://base-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"

anvil = "http://127.0.0.1:8545"

[etherscan]
optimism = {key = "${ETHERSCAN_API_KEY_OPTIMISM}"}
optimism-sepolia = { key = "${ETHERSCAN_API_KEY_OPTIMISM}" }

base = {key = "${ETHERSCAN_API_KEY_BASE}"}
base-sepolia = { key = "${ETHERSCAN_API_KEY_BASE}" }

2 changes: 1 addition & 1 deletion foundry/lib/chainlink
Submodule chainlink updated 1207 files
2 changes: 1 addition & 1 deletion foundry/lib/forge-deploy-lite
2 changes: 1 addition & 1 deletion foundry/lib/forge-std
19 changes: 11 additions & 8 deletions foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@
"author": "",
"description": "",
"dependencies": {
"eslint-plugin-json": "^4.0.1",
"solhint": "^5.0.3"
"eslint-plugin-json": "^4.0.1"
},
"keywords": [],
"license": "ISC",
"main": "index.js",
"name": "@onchain-ai/foundry",
"scripts": {
"all": "pnpm run clean && pnpm run format && pnpm run check && pnpm run build && pnpm run test && pnpm run deploy:anvil",
"clean": "rm -rf node_modules .turbo out broadcast cache",
"format": "forge fmt",
"check": "solhint src/**/*.sol",
"check": "pnpx solhint src/**/*.sol",
"build": "forge compile",
"chain": "./anvil.sh",
"deploy:all": "forge script script/DeployAll.s.sol",
"deploy:anvil": "export CHAIN=anvil ACCOUNT=anvil-deployer && pnpm run chain && pnpm deploy:deploy --password '' && pnpm run deploy:validate",
"deploy:deploy": "pnpm deploy:all --fork-url $CHAIN --account $ACCOUNT --broadcast",
"deploy:validate": "pnpm deploy:all --fork-url $CHAIN",
"deploy:testnet": "ACCOUNT=testnet-deployer pnpm deploy:deploy --verify && pnpm run deploy:validate",
"deploy:mainnet": "ACCOUNT=mainnet-deployer pnpm deploy:deploy --verify && pnpm run deploy:validate",
"deploy:anvil": "export CHAIN=anvil ACCOUNT=anvil-deployer && pnpm run chain && pnpm deploy:deploy --password '' && pnpm run deploy:validate",
"deploy:base": "CHAIN=base pnpm deploy:mainnet",
"deploy:optimism": "CHAIN=optimism pnpm deploy:mainnet",
"deploy:base-sepolia": "CHAIN=base-sepolia pnpm deploy:testnet",
"deploy:optimism-sepolia": "CHAIN=optimism-sepolia pnpm deploy:testnet",
"deploy:testnet": "ACCOUNT=testnet-deployer pnpm deploy:deploy --verify --etherscan-api-key $CHAIN && pnpm run deploy:validate",
"deploy:mainnet": "ACCOUNT=mainnet-deployer pnpm deploy:deploy --verify --etherscan-api-key $CHAIN && pnpm run deploy:validate",
"deploy:validate": "pnpm deploy:all --fork-url $CHAIN",
"test": "forge test"
},
"version": "1.0.1"
"version": "1.0.2",
"devDependencies": {
"solhint": "^5.0.3"
}
}
6 changes: 4 additions & 2 deletions foundry/script/DeployAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ pragma solidity ^0.8.0;
import "forge-std/Script.sol";

import {DeployOnChainAI} from "./DeployOnChainAI.s.sol";
import {DeployCounter} from "./DeployCounter.s.sol";

contract DeployAll is DeployOnChainAI {
function run() public override(DeployOnChainAI) {
contract DeployAll is DeployOnChainAI, DeployCounter {
function run() public override(DeployOnChainAI, DeployCounter) {
console.log("chainId %s", block.chainid);

deployOnChainAI();
// deployCounter();
}
}
15 changes: 15 additions & 0 deletions foundry/script/DeployCounter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {DeployLite} from "@forge-deploy-lite/DeployLite.s.sol";
import {Counter} from "../src/Counter.sol";

contract DeployCounter is DeployLite {
function deployCounter() public returns (address) {
return deployLite("Counter", abi.encode(42));
}

function run() public virtual {
deployCounter();
}
}
14 changes: 14 additions & 0 deletions foundry/src/Counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract Counter {
uint256 public number;

function setNumber(uint256 newNumber) public {
number = newNumber;
}

function increment() public {
number++;
}
}
4 changes: 2 additions & 2 deletions foundry/src/OnChainAIv1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ contract OnChainAIv1 is FunctionsClient, ConfirmedOwner {
setPrice(price_);
}

function lastInteraction() external view returns (Interaction memory) {
return interactions[_lastRequestId[msg.sender]];
function lastInteraction(address sender) external view returns (Interaction memory) {
return interactions[_lastRequestId[sender]];
}

function setJavascript(string memory javascript_) public onlyOwner {
Expand Down
24 changes: 24 additions & 0 deletions foundry/test/Counter.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";

contract CounterTest is Test {
Counter public counter;

function setUp() public {
counter = new Counter();
counter.setNumber(0);
}

function test_Increment() public {
counter.increment();
assertEq(counter.number(), 1);
}

function testFuzz_SetNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
}
Loading

0 comments on commit 9e4c813

Please sign in to comment.