diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index eb1ca0ce8..0c5dad7ab 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -38,7 +38,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: egress-policy: audit @@ -47,7 +47,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0 + uses: github/codeql-action/init@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2.28.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -61,7 +61,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0 + uses: github/codeql-action/autobuild@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2.28.1 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -74,6 +74,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0 + uses: github/codeql-action/analyze@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2.28.1 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/contracts-testing.yml b/.github/workflows/contracts-testing.yml index 0bde272b7..dc0db6014 100644 --- a/.github/workflows/contracts-testing.yml +++ b/.github/workflows/contracts-testing.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: disable-sudo: true egress-policy: block @@ -50,13 +50,13 @@ jobs: yarn set version 4.5.1 - name: Setup Node.js environment - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 with: node-version: 20.x cache: yarn - name: Cache node modules - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1 env: cache-name: cache-node-modules with: @@ -71,7 +71,7 @@ jobs: run: yarn workspace @kleros/kleros-v2-contracts install - name: Install Foundry - uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0 + uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c # v1.3.1 - name: Install lcov run: sudo apt-get install -y lcov @@ -81,7 +81,7 @@ jobs: working-directory: contracts - name: Upload a build artifact - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: code-coverage-report path: contracts/coverage diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index d90d99aea..26288d133 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/deploy-bots.yml b/.github/workflows/deploy-bots.yml index 4794efaad..0529a824a 100644 --- a/.github/workflows/deploy-bots.yml +++ b/.github/workflows/deploy-bots.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs diff --git a/.github/workflows/deploy-subgraph.yml b/.github/workflows/deploy-subgraph.yml index ea0963dcc..e109c13fb 100644 --- a/.github/workflows/deploy-subgraph.yml +++ b/.github/workflows/deploy-subgraph.yml @@ -35,7 +35,7 @@ jobs: environment: ${{ inputs.graph_environment }} steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: egress-policy: audit diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index fcb8916f4..87cf6cd9b 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: disable-sudo: true egress-policy: block @@ -56,7 +56,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0 + uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 with: results_file: results.sarif results_format: sarif @@ -78,7 +78,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: SARIF file path: results.sarif @@ -86,6 +86,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0 + uses: github/codeql-action/upload-sarif@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2.28.1 with: sarif_file: results.sarif diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml index 3f6ae2d50..3c033a888 100644 --- a/.github/workflows/sentry-release.yml +++ b/.github/workflows/sentry-release.yml @@ -17,7 +17,7 @@ jobs: version: ${{ steps.set-version.outputs.version }} steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: disable-sudo: true egress-policy: block @@ -44,13 +44,13 @@ jobs: yarn set version 4.5.1 - name: Setup Node.js environment - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 with: node-version: 20.x cache: yarn - name: Cache node modules - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1 env: cache-name: cache-node-modules with: @@ -72,7 +72,7 @@ jobs: working-directory: web - name: Create Sentry release - uses: getsentry/action-release@f6dfa3d84a1c740b94aa45255c5e032b744a095d # v1.9.0 + uses: getsentry/action-release@ffb64465339ef6fb868e2fc261318d78ae0ed8d9 # v1.10.5 env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index bea307bb3..55444c953 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.3 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: egress-policy: audit diff --git a/contracts/README.md b/contracts/README.md index 2b09dc629..36b23216f 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -19,6 +19,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments - [EvidenceModule: proxy](https://arbiscan.io/address/0x48e052B4A6dC4F30e90930F1CeaAFd83b3981EB3), [implementation](https://arbiscan.io/address/0xE22500Fa27f696d06702367246bd17Bd2C8a4c5d) - [KlerosCoreNeo: proxy](https://arbiscan.io/address/0x991d2df165670b9cac3B022f4B68D65b664222ea), [implementation](https://arbiscan.io/address/0x17c39AB53A7072b167A74a85D47b30385c98ae89) - [KlerosCoreRulerNeo: proxy](https://arbiscan.io/address/0xc0169e0B19aE02ac4fADD689260CF038726DFE13), [implementation](https://arbiscan.io/address/0x85093b5EDa4F2e2E2fEDae34Da91239D6a08e324) +- [KlerosCoreSnapshotProxy](https://arbiscan.io/address/0xEF719a5B3352F607e6C4E17b7e0cDAd8322fEC95) - [KlerosV2NeoEarlyUser](https://arbiscan.io/address/0xfE34a72c55e512601E7d491A9c5b36373cE34d63) - [Pinakion](https://arbiscan.io/address/0x330bD769382cFc6d50175903434CCC8D206DCAE5) - [PolicyRegistry: proxy](https://arbiscan.io/address/0x553dcbF6aB3aE06a1064b5200Df1B5A9fB403d3c), [implementation](https://arbiscan.io/address/0x15E5964C7751dF8563eA4bC000301582C79BC454) @@ -39,6 +40,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments - [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xe763d31Cb096B4bc7294012B78FC7F148324ebcb), [implementation](https://sepolia.arbiscan.io/address/0x7283c07CC5224B20f431B1fa0E6d6db3cA02de34) - [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xA88A9a25cE7f1d8b3941dA3b322Ba91D009E1397), [implementation](https://sepolia.arbiscan.io/address/0x63CF56e1c99E65E4a9eCDCC805F4735E016F2dc8) - [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xE8442307d36e9bf6aB27F1A009F95CE8E11C3479), [implementation](https://sepolia.arbiscan.io/address/0x0766e4B8c4a3aAC9371a5A9D6119E8125Adcfd55) +- [KlerosCoreSnapshotProxy](https://sepolia.arbiscan.io/address/0xd74e61A4dB9C6c3F2C97b62a319aE194f616858C) - [PNKFaucet](https://sepolia.arbiscan.io/address/0x9f6ffc13B685A68ae359fCA128dfE776458Df464) - [PinakionV2](https://sepolia.arbiscan.io/address/0x34B944D42cAcfC8266955D07A80181D2054aa225) - [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0x2668c46A14af8997417138B064ca1bEB70769585), [implementation](https://sepolia.arbiscan.io/address/0xB958113f96950C7806d584eFBed964288d46a0B8) @@ -87,6 +89,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments - [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xA54e7A16d7460e38a8F324eF46782FB520d58CE8), [implementation](https://sepolia.arbiscan.io/address/0x91a373BBdE0532F86410682F362e2Cf685e95085) - [KlerosCoreNeo: proxy](https://sepolia.arbiscan.io/address/0x26bf077037550e437605F07e25EfcAd510715C3A), [implementation](https://sepolia.arbiscan.io/address/0x3bE96b7eAF6A3640DBa1f7CE58776D5b790B74CB) - [KlerosCoreRuler: proxy](https://sepolia.arbiscan.io/address/0x7ffcd32A0521645E6fCFd071A68F0e26957775a5), [implementation](https://sepolia.arbiscan.io/address/0x97e30A3A940856A3913437912C746f1aF6ccC76c) +- [KlerosCoreSnapshotProxy](https://sepolia.arbiscan.io/address/0x9300D415af6e747ADe3C6cbA09a3b3CD5fb0c091) - [KlerosCoreUniversity: proxy](https://sepolia.arbiscan.io/address/0x5AB37F38778Bc175852fA353056591D91c744ce6), [implementation](https://sepolia.arbiscan.io/address/0xF74DaBfC5F5dbdBD07636637204d9C35326D2906) - [KlerosV2NeoEarlyUser](https://sepolia.arbiscan.io/address/0x0d60Ff8bbCF49Bc5352328E7E28e141834d7750F) - [PNKFaucet](https://sepolia.arbiscan.io/address/0x7EFE468003Ad6A858b5350CDE0A67bBED58739dD) diff --git a/contracts/deploy/00-home-chain-arbitration-neo.ts b/contracts/deploy/00-home-chain-arbitration-neo.ts index 3aa5ceac9..c4530604e 100644 --- a/contracts/deploy/00-home-chain-arbitration-neo.ts +++ b/contracts/deploy/00-home-chain-arbitration-neo.ts @@ -122,6 +122,12 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) console.log(`core.changeArbitrableWhitelist(${resolver.address}, true)`); await core.changeArbitrableWhitelist(resolver.address, true); + + await deploy("KlerosCoreSnapshotProxy", { + from: deployer, + args: [deployer, core.target], + log: true, + }); }; deployArbitration.tags = ["ArbitrationNeo"]; diff --git a/contracts/deploy/00-home-chain-arbitration.ts b/contracts/deploy/00-home-chain-arbitration.ts index 559453910..e61805f31 100644 --- a/contracts/deploy/00-home-chain-arbitration.ts +++ b/contracts/deploy/00-home-chain-arbitration.ts @@ -10,6 +10,7 @@ import { ChainlinkRNG, DisputeKitClassic, KlerosCore } from "../typechain-types" const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const { ethers, deployments, getNamedAccounts, getChainId } = hre; + const { deploy } = deployments; const { ZeroAddress } = hre.ethers; const RNG_LOOKAHEAD = 20; @@ -94,6 +95,12 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) } catch (e) { console.error("failed to change currency rates:", e); } + + await deploy("KlerosCoreSnapshotProxy", { + from: deployer, + args: [deployer, core.target], + log: true, + }); }; deployArbitration.tags = ["Arbitration"]; diff --git a/contracts/deployments/arbitrum/KlerosCoreSnapshotProxy.json b/contracts/deployments/arbitrum/KlerosCoreSnapshotProxy.json new file mode 100644 index 000000000..69426d3f2 --- /dev/null +++ b/contracts/deployments/arbitrum/KlerosCoreSnapshotProxy.json @@ -0,0 +1,228 @@ +{ + "address": "0xEF719a5B3352F607e6C4E17b7e0cDAd8322fEC95", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + }, + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "totalStaked", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "name": "changeCore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + } + ], + "name": "changeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract IKlerosCore", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x9519002826064774768f0756c58d55c3f908265e0437de0cb6794f193df7bab4", + "receipt": { + "to": null, + "from": "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "contractAddress": "0xEF719a5B3352F607e6C4E17b7e0cDAd8322fEC95", + "transactionIndex": 2, + "gasUsed": "381513", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x377819384e975cdff6f1207252d20ff63dae97c6e6f5e30a0ef4c0690e05362e", + "transactionHash": "0x9519002826064774768f0756c58d55c3f908265e0437de0cb6794f193df7bab4", + "logs": [], + "blockNumber": 303002159, + "cumulativeGasUsed": "1057838", + "status": 1, + "byzantium": true + }, + "args": [ + "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "0x991d2df165670b9cac3B022f4B68D65b664222ea" + ], + "numDeployments": 1, + "solcInputHash": "ede3f7f4426109631936df3b8acee8f2", + "metadata": "{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"},{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalStaked\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"name\":\"changeCore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"}],\"name\":\"changeGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"core\",\"outputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"balanceOf(address)\":{\"details\":\"Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\",\"params\":{\"_account\":\"The address to query.\"},\"returns\":{\"totalStaked\":\"Total amount staked in V2 by the address.\"}},\"changeCore(address)\":{\"details\":\"Changes the `core` storage variable.\",\"params\":{\"_core\":\"The new value for the `core` storage variable.\"}},\"changeGovernor(address)\":{\"details\":\"Changes the `governor` storage variable.\",\"params\":{\"_governor\":\"The new value for the `governor` storage variable.\"}},\"constructor\":{\"details\":\"Constructor\",\"params\":{\"_core\":\"KlerosCore to read the balance from.\",\"_governor\":\"The governor of the contract.\"}}},\"title\":\"KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":\"KlerosCoreSnapshotProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":100},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC-20 standard as defined in the ERC.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xe06a3f08a987af6ad2e1c1e774405d4fe08f1694b67517438b467cecf0da0ef7\",\"license\":\"MIT\"},\"src/arbitration/interfaces/ISortitionModule.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.24;\\n\\nimport \\\"../../libraries/Constants.sol\\\";\\n\\ninterface ISortitionModule {\\n enum Phase {\\n staking, // Stake sum trees can be updated. Pass after `minStakingTime` passes and there is at least one dispute without jurors.\\n generating, // Waiting for a random number. Pass as soon as it is ready.\\n drawing // Jurors can be drawn. Pass after all disputes have jurors or `maxDrawingTime` passes.\\n }\\n\\n event NewPhase(Phase _phase);\\n\\n function createTree(bytes32 _key, bytes memory _extraData) external;\\n\\n function setStake(\\n address _account,\\n uint96 _courtID,\\n uint256 _newStake,\\n bool _alreadyTransferred\\n ) external returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult);\\n\\n function setJurorInactive(address _account) external;\\n\\n function lockStake(address _account, uint256 _relativeAmount) external;\\n\\n function unlockStake(address _account, uint256 _relativeAmount) external;\\n\\n function penalizeStake(address _account, uint256 _relativeAmount) external;\\n\\n function notifyRandomNumber(uint256 _drawnNumber) external;\\n\\n function draw(bytes32 _court, uint256 _coreDisputeID, uint256 _nonce) external view returns (address);\\n\\n function getJurorBalance(\\n address _juror,\\n uint96 _courtID\\n ) external view returns (uint256 totalStaked, uint256 totalLocked, uint256 stakedInCourt, uint256 nbCourts);\\n\\n function getJurorCourtIDs(address _juror) external view returns (uint96[] memory);\\n\\n function isJurorStaked(address _juror) external view returns (bool);\\n\\n function createDisputeHook(uint256 _disputeID, uint256 _roundID) external;\\n\\n function postDrawHook(uint256 _disputeID, uint256 _roundID) external;\\n}\\n\",\"keccak256\":\"0x18a4ff126bb51e7b5b0e3fbff7cf0dbbcfff7195ad79307e69cdbc9226e63502\",\"license\":\"MIT\"},\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n/// @custom:authors: [@unknownunknown1]\\n/// @custom:reviewers: []\\n/// @custom:auditors: []\\n/// @custom:bounties: []\\n/// @custom:deployments: []\\n\\npragma solidity 0.8.24;\\n\\nimport {ISortitionModule} from \\\"../interfaces/ISortitionModule.sol\\\";\\n\\ninterface IKlerosCore {\\n function sortitionModule() external view returns (ISortitionModule);\\n}\\n\\n/// @title KlerosCoreSnapshotProxy\\n/// Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\\ncontract KlerosCoreSnapshotProxy {\\n // ************************************* //\\n // * State Modifiers * //\\n // ************************************* //\\n\\n IKlerosCore public core;\\n address public governor;\\n string public constant name = \\\"Staked Pinakion\\\";\\n string public constant symbol = \\\"stPNK\\\";\\n uint8 public constant decimals = 18;\\n\\n // ************************************* //\\n // * Modifiers * //\\n // ************************************* //\\n\\n modifier onlyByGovernor() {\\n require(governor == msg.sender, \\\"Access not allowed: Governor only.\\\");\\n _;\\n }\\n\\n // ************************************* //\\n // * Constructor * //\\n // ************************************* //\\n\\n /// @dev Constructor\\n /// @param _governor The governor of the contract.\\n /// @param _core KlerosCore to read the balance from.\\n constructor(address _governor, IKlerosCore _core) {\\n governor = _governor;\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Governance * //\\n // ************************************* //\\n\\n /// @dev Changes the `governor` storage variable.\\n /// @param _governor The new value for the `governor` storage variable.\\n function changeGovernor(address _governor) external onlyByGovernor {\\n governor = _governor;\\n }\\n\\n /// @dev Changes the `core` storage variable.\\n /// @param _core The new value for the `core` storage variable.\\n function changeCore(IKlerosCore _core) external onlyByGovernor {\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Public Views * //\\n // ************************************* //\\n\\n /// @dev Returns the amount of PNK staked in KlerosV2 for a particular address.\\n /// Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\\n /// @param _account The address to query.\\n /// @return totalStaked Total amount staked in V2 by the address.\\n function balanceOf(address _account) external view returns (uint256 totalStaked) {\\n (totalStaked, , , ) = core.sortitionModule().getJurorBalance(_account, 0);\\n }\\n}\\n\",\"keccak256\":\"0xf9516838d21bc8b4d8776d8d8b0b17d46ebb3d0940c055c09944f7f35adfd99d\",\"license\":\"MIT\"},\"src/libraries/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.24;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n// Courts\\nuint96 constant FORKING_COURT = 0; // Index of the forking court.\\nuint96 constant GENERAL_COURT = 1; // Index of the default (general) court.\\n\\n// Dispute Kits\\nuint256 constant NULL_DISPUTE_KIT = 0; // Null pattern to indicate a top-level DK which has no parent. DEPRECATED, as its main purpose was to accommodate forest structure which is not used now.\\nuint256 constant DISPUTE_KIT_CLASSIC = 1; // Index of the default DK. 0 index is skipped.\\n\\n// Sortition Module\\nuint256 constant MAX_STAKE_PATHS = 4; // The maximum number of stake paths a juror can have.\\nuint256 constant DEFAULT_K = 6; // Default number of children per node.\\n\\n// Defaults\\nuint256 constant DEFAULT_NB_OF_JURORS = 3; // The default number of jurors in a dispute.\\nIERC20 constant NATIVE_CURRENCY = IERC20(address(0)); // The native currency, such as ETH on Arbitrum, Optimism and Ethereum L1.\\n\\nenum OnError {\\n Revert,\\n Return\\n}\\n\\nenum StakingResult {\\n Successful,\\n StakingTransferFailed,\\n UnstakingTransferFailed,\\n CannotStakeInMoreCourts,\\n CannotStakeInThisCourt,\\n CannotStakeLessThanMinStake,\\n CannotStakeMoreThanMaxStakePerJuror,\\n CannotStakeMoreThanMaxTotalStaked,\\n CannotStakeZeroWhenNoStake\\n}\\n\",\"keccak256\":\"0x5bbda7c304b3681b90feae33be694d04dc129edd60e1d07cb593b895fdc9cd4e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5060405161053338038061053383398101604081905261002f91610078565b600180546001600160a01b039384166001600160a01b031991821617909155600080549290931691161790556100b2565b6001600160a01b038116811461007557600080fd5b50565b6000806040838503121561008b57600080fd5b825161009681610060565b60208401519092506100a781610060565b809150509250929050565b610472806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "devdoc": { + "kind": "dev", + "methods": { + "balanceOf(address)": { + "details": "Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.", + "params": { + "_account": "The address to query." + }, + "returns": { + "totalStaked": "Total amount staked in V2 by the address." + } + }, + "changeCore(address)": { + "details": "Changes the `core` storage variable.", + "params": { + "_core": "The new value for the `core` storage variable." + } + }, + "changeGovernor(address)": { + "details": "Changes the `governor` storage variable.", + "params": { + "_governor": "The new value for the `governor` storage variable." + } + }, + "constructor": { + "details": "Constructor", + "params": { + "_core": "KlerosCore to read the balance from.", + "_governor": "The governor of the contract." + } + } + }, + "title": "KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 216, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "core", + "offset": 0, + "slot": "0", + "type": "t_contract(IKlerosCore)212" + }, + { + "astId": 218, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "governor", + "offset": 0, + "slot": "1", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_contract(IKlerosCore)212": { + "encoding": "inplace", + "label": "contract IKlerosCore", + "numberOfBytes": "20" + } + } + } +} diff --git a/contracts/deployments/arbitrumSepolia/KlerosCoreSnapshotProxy.json b/contracts/deployments/arbitrumSepolia/KlerosCoreSnapshotProxy.json new file mode 100644 index 000000000..d24c1bea4 --- /dev/null +++ b/contracts/deployments/arbitrumSepolia/KlerosCoreSnapshotProxy.json @@ -0,0 +1,228 @@ +{ + "address": "0xd74e61A4dB9C6c3F2C97b62a319aE194f616858C", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + }, + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "totalStaked", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "name": "changeCore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + } + ], + "name": "changeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract IKlerosCore", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x951a0309da4f71c199c36e0004ba7a67e1c68f4135942ee062040b6bf4edcf2f", + "receipt": { + "to": null, + "from": "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "contractAddress": "0xd74e61A4dB9C6c3F2C97b62a319aE194f616858C", + "transactionIndex": 1, + "gasUsed": "363319", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xa62b5ceb98b8de3cd5d3f142c7384221d1d823adb28dcc8c9ae7945f22542274", + "transactionHash": "0x951a0309da4f71c199c36e0004ba7a67e1c68f4135942ee062040b6bf4edcf2f", + "logs": [], + "blockNumber": 121346526, + "cumulativeGasUsed": "363319", + "status": 1, + "byzantium": true + }, + "args": [ + "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "0xE8442307d36e9bf6aB27F1A009F95CE8E11C3479" + ], + "numDeployments": 1, + "solcInputHash": "ede3f7f4426109631936df3b8acee8f2", + "metadata": "{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"},{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalStaked\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"name\":\"changeCore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"}],\"name\":\"changeGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"core\",\"outputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"balanceOf(address)\":{\"details\":\"Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\",\"params\":{\"_account\":\"The address to query.\"},\"returns\":{\"totalStaked\":\"Total amount staked in V2 by the address.\"}},\"changeCore(address)\":{\"details\":\"Changes the `core` storage variable.\",\"params\":{\"_core\":\"The new value for the `core` storage variable.\"}},\"changeGovernor(address)\":{\"details\":\"Changes the `governor` storage variable.\",\"params\":{\"_governor\":\"The new value for the `governor` storage variable.\"}},\"constructor\":{\"details\":\"Constructor\",\"params\":{\"_core\":\"KlerosCore to read the balance from.\",\"_governor\":\"The governor of the contract.\"}}},\"title\":\"KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":\"KlerosCoreSnapshotProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":100},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC-20 standard as defined in the ERC.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xe06a3f08a987af6ad2e1c1e774405d4fe08f1694b67517438b467cecf0da0ef7\",\"license\":\"MIT\"},\"src/arbitration/interfaces/ISortitionModule.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.24;\\n\\nimport \\\"../../libraries/Constants.sol\\\";\\n\\ninterface ISortitionModule {\\n enum Phase {\\n staking, // Stake sum trees can be updated. Pass after `minStakingTime` passes and there is at least one dispute without jurors.\\n generating, // Waiting for a random number. Pass as soon as it is ready.\\n drawing // Jurors can be drawn. Pass after all disputes have jurors or `maxDrawingTime` passes.\\n }\\n\\n event NewPhase(Phase _phase);\\n\\n function createTree(bytes32 _key, bytes memory _extraData) external;\\n\\n function setStake(\\n address _account,\\n uint96 _courtID,\\n uint256 _newStake,\\n bool _alreadyTransferred\\n ) external returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult);\\n\\n function setJurorInactive(address _account) external;\\n\\n function lockStake(address _account, uint256 _relativeAmount) external;\\n\\n function unlockStake(address _account, uint256 _relativeAmount) external;\\n\\n function penalizeStake(address _account, uint256 _relativeAmount) external;\\n\\n function notifyRandomNumber(uint256 _drawnNumber) external;\\n\\n function draw(bytes32 _court, uint256 _coreDisputeID, uint256 _nonce) external view returns (address);\\n\\n function getJurorBalance(\\n address _juror,\\n uint96 _courtID\\n ) external view returns (uint256 totalStaked, uint256 totalLocked, uint256 stakedInCourt, uint256 nbCourts);\\n\\n function getJurorCourtIDs(address _juror) external view returns (uint96[] memory);\\n\\n function isJurorStaked(address _juror) external view returns (bool);\\n\\n function createDisputeHook(uint256 _disputeID, uint256 _roundID) external;\\n\\n function postDrawHook(uint256 _disputeID, uint256 _roundID) external;\\n}\\n\",\"keccak256\":\"0x18a4ff126bb51e7b5b0e3fbff7cf0dbbcfff7195ad79307e69cdbc9226e63502\",\"license\":\"MIT\"},\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n/// @custom:authors: [@unknownunknown1]\\n/// @custom:reviewers: []\\n/// @custom:auditors: []\\n/// @custom:bounties: []\\n/// @custom:deployments: []\\n\\npragma solidity 0.8.24;\\n\\nimport {ISortitionModule} from \\\"../interfaces/ISortitionModule.sol\\\";\\n\\ninterface IKlerosCore {\\n function sortitionModule() external view returns (ISortitionModule);\\n}\\n\\n/// @title KlerosCoreSnapshotProxy\\n/// Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\\ncontract KlerosCoreSnapshotProxy {\\n // ************************************* //\\n // * State Modifiers * //\\n // ************************************* //\\n\\n IKlerosCore public core;\\n address public governor;\\n string public constant name = \\\"Staked Pinakion\\\";\\n string public constant symbol = \\\"stPNK\\\";\\n uint8 public constant decimals = 18;\\n\\n // ************************************* //\\n // * Modifiers * //\\n // ************************************* //\\n\\n modifier onlyByGovernor() {\\n require(governor == msg.sender, \\\"Access not allowed: Governor only.\\\");\\n _;\\n }\\n\\n // ************************************* //\\n // * Constructor * //\\n // ************************************* //\\n\\n /// @dev Constructor\\n /// @param _governor The governor of the contract.\\n /// @param _core KlerosCore to read the balance from.\\n constructor(address _governor, IKlerosCore _core) {\\n governor = _governor;\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Governance * //\\n // ************************************* //\\n\\n /// @dev Changes the `governor` storage variable.\\n /// @param _governor The new value for the `governor` storage variable.\\n function changeGovernor(address _governor) external onlyByGovernor {\\n governor = _governor;\\n }\\n\\n /// @dev Changes the `core` storage variable.\\n /// @param _core The new value for the `core` storage variable.\\n function changeCore(IKlerosCore _core) external onlyByGovernor {\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Public Views * //\\n // ************************************* //\\n\\n /// @dev Returns the amount of PNK staked in KlerosV2 for a particular address.\\n /// Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\\n /// @param _account The address to query.\\n /// @return totalStaked Total amount staked in V2 by the address.\\n function balanceOf(address _account) external view returns (uint256 totalStaked) {\\n (totalStaked, , , ) = core.sortitionModule().getJurorBalance(_account, 0);\\n }\\n}\\n\",\"keccak256\":\"0xf9516838d21bc8b4d8776d8d8b0b17d46ebb3d0940c055c09944f7f35adfd99d\",\"license\":\"MIT\"},\"src/libraries/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.24;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n// Courts\\nuint96 constant FORKING_COURT = 0; // Index of the forking court.\\nuint96 constant GENERAL_COURT = 1; // Index of the default (general) court.\\n\\n// Dispute Kits\\nuint256 constant NULL_DISPUTE_KIT = 0; // Null pattern to indicate a top-level DK which has no parent. DEPRECATED, as its main purpose was to accommodate forest structure which is not used now.\\nuint256 constant DISPUTE_KIT_CLASSIC = 1; // Index of the default DK. 0 index is skipped.\\n\\n// Sortition Module\\nuint256 constant MAX_STAKE_PATHS = 4; // The maximum number of stake paths a juror can have.\\nuint256 constant DEFAULT_K = 6; // Default number of children per node.\\n\\n// Defaults\\nuint256 constant DEFAULT_NB_OF_JURORS = 3; // The default number of jurors in a dispute.\\nIERC20 constant NATIVE_CURRENCY = IERC20(address(0)); // The native currency, such as ETH on Arbitrum, Optimism and Ethereum L1.\\n\\nenum OnError {\\n Revert,\\n Return\\n}\\n\\nenum StakingResult {\\n Successful,\\n StakingTransferFailed,\\n UnstakingTransferFailed,\\n CannotStakeInMoreCourts,\\n CannotStakeInThisCourt,\\n CannotStakeLessThanMinStake,\\n CannotStakeMoreThanMaxStakePerJuror,\\n CannotStakeMoreThanMaxTotalStaked,\\n CannotStakeZeroWhenNoStake\\n}\\n\",\"keccak256\":\"0x5bbda7c304b3681b90feae33be694d04dc129edd60e1d07cb593b895fdc9cd4e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5060405161053338038061053383398101604081905261002f91610078565b600180546001600160a01b039384166001600160a01b031991821617909155600080549290931691161790556100b2565b6001600160a01b038116811461007557600080fd5b50565b6000806040838503121561008b57600080fd5b825161009681610060565b60208401519092506100a781610060565b809150509250929050565b610472806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "devdoc": { + "kind": "dev", + "methods": { + "balanceOf(address)": { + "details": "Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.", + "params": { + "_account": "The address to query." + }, + "returns": { + "totalStaked": "Total amount staked in V2 by the address." + } + }, + "changeCore(address)": { + "details": "Changes the `core` storage variable.", + "params": { + "_core": "The new value for the `core` storage variable." + } + }, + "changeGovernor(address)": { + "details": "Changes the `governor` storage variable.", + "params": { + "_governor": "The new value for the `governor` storage variable." + } + }, + "constructor": { + "details": "Constructor", + "params": { + "_core": "KlerosCore to read the balance from.", + "_governor": "The governor of the contract." + } + } + }, + "title": "KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 216, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "core", + "offset": 0, + "slot": "0", + "type": "t_contract(IKlerosCore)212" + }, + { + "astId": 218, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "governor", + "offset": 0, + "slot": "1", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_contract(IKlerosCore)212": { + "encoding": "inplace", + "label": "contract IKlerosCore", + "numberOfBytes": "20" + } + } + } +} diff --git a/contracts/deployments/arbitrumSepoliaDevnet/KlerosCoreSnapshotProxy.json b/contracts/deployments/arbitrumSepoliaDevnet/KlerosCoreSnapshotProxy.json new file mode 100644 index 000000000..f02b3234c --- /dev/null +++ b/contracts/deployments/arbitrumSepoliaDevnet/KlerosCoreSnapshotProxy.json @@ -0,0 +1,228 @@ +{ + "address": "0x9300D415af6e747ADe3C6cbA09a3b3CD5fb0c091", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + }, + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "totalStaked", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IKlerosCore", + "name": "_core", + "type": "address" + } + ], + "name": "changeCore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_governor", + "type": "address" + } + ], + "name": "changeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract IKlerosCore", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x021bfe3731521c0619fa56f401c3873dad4e4b330d34f727bb401226b8120edf", + "receipt": { + "to": null, + "from": "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "contractAddress": "0x9300D415af6e747ADe3C6cbA09a3b3CD5fb0c091", + "transactionIndex": 1, + "gasUsed": "363333", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc565952e226bb538ebd218e89b7923eb2517fb3ffcf5202fb1e1ccacbc1c30e5", + "transactionHash": "0x021bfe3731521c0619fa56f401c3873dad4e4b330d34f727bb401226b8120edf", + "logs": [], + "blockNumber": 121346480, + "cumulativeGasUsed": "363333", + "status": 1, + "byzantium": true + }, + "args": [ + "0xf1C7c037891525E360C59f708739Ac09A7670c59", + "0xA54e7A16d7460e38a8F324eF46782FB520d58CE8" + ], + "numDeployments": 1, + "solcInputHash": "ede3f7f4426109631936df3b8acee8f2", + "metadata": "{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"},{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalStaked\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"_core\",\"type\":\"address\"}],\"name\":\"changeCore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_governor\",\"type\":\"address\"}],\"name\":\"changeGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"core\",\"outputs\":[{\"internalType\":\"contract IKlerosCore\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"balanceOf(address)\":{\"details\":\"Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\",\"params\":{\"_account\":\"The address to query.\"},\"returns\":{\"totalStaked\":\"Total amount staked in V2 by the address.\"}},\"changeCore(address)\":{\"details\":\"Changes the `core` storage variable.\",\"params\":{\"_core\":\"The new value for the `core` storage variable.\"}},\"changeGovernor(address)\":{\"details\":\"Changes the `governor` storage variable.\",\"params\":{\"_governor\":\"The new value for the `governor` storage variable.\"}},\"constructor\":{\"details\":\"Constructor\",\"params\":{\"_core\":\"KlerosCore to read the balance from.\",\"_governor\":\"The governor of the contract.\"}}},\"title\":\"KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":\"KlerosCoreSnapshotProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":100},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC-20 standard as defined in the ERC.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xe06a3f08a987af6ad2e1c1e774405d4fe08f1694b67517438b467cecf0da0ef7\",\"license\":\"MIT\"},\"src/arbitration/interfaces/ISortitionModule.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.8.24;\\n\\nimport \\\"../../libraries/Constants.sol\\\";\\n\\ninterface ISortitionModule {\\n enum Phase {\\n staking, // Stake sum trees can be updated. Pass after `minStakingTime` passes and there is at least one dispute without jurors.\\n generating, // Waiting for a random number. Pass as soon as it is ready.\\n drawing // Jurors can be drawn. Pass after all disputes have jurors or `maxDrawingTime` passes.\\n }\\n\\n event NewPhase(Phase _phase);\\n\\n function createTree(bytes32 _key, bytes memory _extraData) external;\\n\\n function setStake(\\n address _account,\\n uint96 _courtID,\\n uint256 _newStake,\\n bool _alreadyTransferred\\n ) external returns (uint256 pnkDeposit, uint256 pnkWithdrawal, StakingResult stakingResult);\\n\\n function setJurorInactive(address _account) external;\\n\\n function lockStake(address _account, uint256 _relativeAmount) external;\\n\\n function unlockStake(address _account, uint256 _relativeAmount) external;\\n\\n function penalizeStake(address _account, uint256 _relativeAmount) external;\\n\\n function notifyRandomNumber(uint256 _drawnNumber) external;\\n\\n function draw(bytes32 _court, uint256 _coreDisputeID, uint256 _nonce) external view returns (address);\\n\\n function getJurorBalance(\\n address _juror,\\n uint96 _courtID\\n ) external view returns (uint256 totalStaked, uint256 totalLocked, uint256 stakedInCourt, uint256 nbCourts);\\n\\n function getJurorCourtIDs(address _juror) external view returns (uint96[] memory);\\n\\n function isJurorStaked(address _juror) external view returns (bool);\\n\\n function createDisputeHook(uint256 _disputeID, uint256 _roundID) external;\\n\\n function postDrawHook(uint256 _disputeID, uint256 _roundID) external;\\n}\\n\",\"keccak256\":\"0x18a4ff126bb51e7b5b0e3fbff7cf0dbbcfff7195ad79307e69cdbc9226e63502\",\"license\":\"MIT\"},\"src/arbitration/view/KlerosCoreSnapshotProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n/// @custom:authors: [@unknownunknown1]\\n/// @custom:reviewers: []\\n/// @custom:auditors: []\\n/// @custom:bounties: []\\n/// @custom:deployments: []\\n\\npragma solidity 0.8.24;\\n\\nimport {ISortitionModule} from \\\"../interfaces/ISortitionModule.sol\\\";\\n\\ninterface IKlerosCore {\\n function sortitionModule() external view returns (ISortitionModule);\\n}\\n\\n/// @title KlerosCoreSnapshotProxy\\n/// Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.\\ncontract KlerosCoreSnapshotProxy {\\n // ************************************* //\\n // * State Modifiers * //\\n // ************************************* //\\n\\n IKlerosCore public core;\\n address public governor;\\n string public constant name = \\\"Staked Pinakion\\\";\\n string public constant symbol = \\\"stPNK\\\";\\n uint8 public constant decimals = 18;\\n\\n // ************************************* //\\n // * Modifiers * //\\n // ************************************* //\\n\\n modifier onlyByGovernor() {\\n require(governor == msg.sender, \\\"Access not allowed: Governor only.\\\");\\n _;\\n }\\n\\n // ************************************* //\\n // * Constructor * //\\n // ************************************* //\\n\\n /// @dev Constructor\\n /// @param _governor The governor of the contract.\\n /// @param _core KlerosCore to read the balance from.\\n constructor(address _governor, IKlerosCore _core) {\\n governor = _governor;\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Governance * //\\n // ************************************* //\\n\\n /// @dev Changes the `governor` storage variable.\\n /// @param _governor The new value for the `governor` storage variable.\\n function changeGovernor(address _governor) external onlyByGovernor {\\n governor = _governor;\\n }\\n\\n /// @dev Changes the `core` storage variable.\\n /// @param _core The new value for the `core` storage variable.\\n function changeCore(IKlerosCore _core) external onlyByGovernor {\\n core = _core;\\n }\\n\\n // ************************************* //\\n // * Public Views * //\\n // ************************************* //\\n\\n /// @dev Returns the amount of PNK staked in KlerosV2 for a particular address.\\n /// Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.\\n /// @param _account The address to query.\\n /// @return totalStaked Total amount staked in V2 by the address.\\n function balanceOf(address _account) external view returns (uint256 totalStaked) {\\n (totalStaked, , , ) = core.sortitionModule().getJurorBalance(_account, 0);\\n }\\n}\\n\",\"keccak256\":\"0xf9516838d21bc8b4d8776d8d8b0b17d46ebb3d0940c055c09944f7f35adfd99d\",\"license\":\"MIT\"},\"src/libraries/Constants.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.24;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n// Courts\\nuint96 constant FORKING_COURT = 0; // Index of the forking court.\\nuint96 constant GENERAL_COURT = 1; // Index of the default (general) court.\\n\\n// Dispute Kits\\nuint256 constant NULL_DISPUTE_KIT = 0; // Null pattern to indicate a top-level DK which has no parent. DEPRECATED, as its main purpose was to accommodate forest structure which is not used now.\\nuint256 constant DISPUTE_KIT_CLASSIC = 1; // Index of the default DK. 0 index is skipped.\\n\\n// Sortition Module\\nuint256 constant MAX_STAKE_PATHS = 4; // The maximum number of stake paths a juror can have.\\nuint256 constant DEFAULT_K = 6; // Default number of children per node.\\n\\n// Defaults\\nuint256 constant DEFAULT_NB_OF_JURORS = 3; // The default number of jurors in a dispute.\\nIERC20 constant NATIVE_CURRENCY = IERC20(address(0)); // The native currency, such as ETH on Arbitrum, Optimism and Ethereum L1.\\n\\nenum OnError {\\n Revert,\\n Return\\n}\\n\\nenum StakingResult {\\n Successful,\\n StakingTransferFailed,\\n UnstakingTransferFailed,\\n CannotStakeInMoreCourts,\\n CannotStakeInThisCourt,\\n CannotStakeLessThanMinStake,\\n CannotStakeMoreThanMaxStakePerJuror,\\n CannotStakeMoreThanMaxTotalStaked,\\n CannotStakeZeroWhenNoStake\\n}\\n\",\"keccak256\":\"0x5bbda7c304b3681b90feae33be694d04dc129edd60e1d07cb593b895fdc9cd4e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5060405161053338038061053383398101604081905261002f91610078565b600180546001600160a01b039384166001600160a01b031991821617909155600080549290931691161790556100b2565b6001600160a01b038116811461007557600080fd5b50565b6000806040838503121561008b57600080fd5b825161009681610060565b60208401519092506100a781610060565b809150509250929050565b610472806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100785760003560e01c806306fdde031461007d5780630c340a24146100c1578063313ce567146100ec57806370a08231146101065780638e4264601461012757806395d89b411461013c578063e4c0aaf414610160578063f2f4eb2614610173575b600080fd5b6100ab6040518060400160405280600f81526020016e29ba30b5b2b2102834b730b5b4b7b760891b81525081565b6040516100b8919061031c565b60405180910390f35b6001546100d4906001600160a01b031681565b6040516001600160a01b0390911681526020016100b8565b6100f4601281565b60405160ff90911681526020016100b8565b610119610114366004610383565b610186565b6040519081526020016100b8565b61013a610135366004610383565b61027b565b005b6100ab604051806040016040528060058152602001647374504e4b60d81b81525081565b61013a61016e366004610383565b6102d0565b6000546100d4906001600160a01b031681565b60008060009054906101000a90046001600160a01b03166001600160a01b0316632e1daf2f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906103a7565b604051631a383be960e31b81526001600160a01b03848116600483015260006024830152919091169063d1c1df4890604401608060405180830381865afa15801561024d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027191906103c4565b5091949350505050565b6001546001600160a01b031633146102ae5760405162461bcd60e51b81526004016102a5906103fa565b60405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031633146102fa5760405162461bcd60e51b81526004016102a5906103fa565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60006020808352835180602085015260005b8181101561034a5785810183015185820160400152820161032e565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038057600080fd5b50565b60006020828403121561039557600080fd5b81356103a08161036b565b9392505050565b6000602082840312156103b957600080fd5b81516103a08161036b565b600080600080608085870312156103da57600080fd5b505082516020840151604085015160609095015191969095509092509050565b60208082526022908201527f416363657373206e6f7420616c6c6f7765643a20476f7665726e6f72206f6e6c6040820152613c9760f11b60608201526080019056fea2646970667358221220ae7b8da51562210a09a90e77fc37c7a9669fa0ff5f919ec51b43ac365aace78464736f6c63430008180033", + "devdoc": { + "kind": "dev", + "methods": { + "balanceOf(address)": { + "details": "Returns the amount of PNK staked in KlerosV2 for a particular address. Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID.", + "params": { + "_account": "The address to query." + }, + "returns": { + "totalStaked": "Total amount staked in V2 by the address." + } + }, + "changeCore(address)": { + "details": "Changes the `core` storage variable.", + "params": { + "_core": "The new value for the `core` storage variable." + } + }, + "changeGovernor(address)": { + "details": "Changes the `governor` storage variable.", + "params": { + "_governor": "The new value for the `governor` storage variable." + } + }, + "constructor": { + "details": "Constructor", + "params": { + "_core": "KlerosCore to read the balance from.", + "_governor": "The governor of the contract." + } + } + }, + "title": "KlerosCoreSnapshotProxy Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 216, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "core", + "offset": 0, + "slot": "0", + "type": "t_contract(IKlerosCore)212" + }, + { + "astId": 218, + "contract": "src/arbitration/view/KlerosCoreSnapshotProxy.sol:KlerosCoreSnapshotProxy", + "label": "governor", + "offset": 0, + "slot": "1", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_contract(IKlerosCore)212": { + "encoding": "inplace", + "label": "contract IKlerosCore", + "numberOfBytes": "20" + } + } + } +} diff --git a/contracts/package.json b/contracts/package.json index 89adff2e7..dde99b2f0 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -11,7 +11,7 @@ "node": ">=16.0.0" }, "volta": { - "node": "18.19.0" + "node": "18.20.6" }, "publishConfig": { "access": "public", @@ -73,7 +73,7 @@ "@kleros/kleros-v2-eslint-config": "workspace:^", "@kleros/kleros-v2-prettier-config": "workspace:^", "@kleros/kleros-v2-tsconfig": "workspace:^", - "@logtail/pino": "^0.4.22", + "@logtail/pino": "^0.5.0", "@nomicfoundation/hardhat-chai-matchers": "^2.0.8", "@nomicfoundation/hardhat-ethers": "^3.0.8", "@nomiclabs/hardhat-solhint": "^4.0.1", diff --git a/contracts/src/arbitration/KlerosCore.sol b/contracts/src/arbitration/KlerosCore.sol index ceaa6b4e0..771a9eefd 100644 --- a/contracts/src/arbitration/KlerosCore.sol +++ b/contracts/src/arbitration/KlerosCore.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {KlerosCoreBase, IDisputeKit, ISortitionModule, IERC20} from "./KlerosCoreBase.sol"; diff --git a/contracts/src/arbitration/KlerosCoreBase.sol b/contracts/src/arbitration/KlerosCoreBase.sol index 85541c5fa..ae743ea30 100644 --- a/contracts/src/arbitration/KlerosCoreBase.sol +++ b/contracts/src/arbitration/KlerosCoreBase.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitratorV2.sol"; diff --git a/contracts/src/arbitration/KlerosCoreNeo.sol b/contracts/src/arbitration/KlerosCoreNeo.sol index 205a50720..87bbdfeee 100644 --- a/contracts/src/arbitration/KlerosCoreNeo.sol +++ b/contracts/src/arbitration/KlerosCoreNeo.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {KlerosCoreBase, IDisputeKit, ISortitionModule, IERC20, OnError, StakingResult} from "./KlerosCoreBase.sol"; diff --git a/contracts/src/arbitration/KlerosGovernor.sol b/contracts/src/arbitration/KlerosGovernor.sol index 8de9a175a..f928ea83d 100644 --- a/contracts/src/arbitration/KlerosGovernor.sol +++ b/contracts/src/arbitration/KlerosGovernor.sol @@ -1,10 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitrableV2.sol"; diff --git a/contracts/src/arbitration/arbitrables/DisputeResolver.sol b/contracts/src/arbitration/arbitrables/DisputeResolver.sol index dff666aa1..fcbcc0d84 100644 --- a/contracts/src/arbitration/arbitrables/DisputeResolver.sol +++ b/contracts/src/arbitration/arbitrables/DisputeResolver.sol @@ -1,10 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] - import {IArbitrableV2, IArbitratorV2} from "../interfaces/IArbitrableV2.sol"; import "../interfaces/IDisputeTemplateRegistry.sol"; diff --git a/contracts/src/arbitration/devtools/DisputeResolverRuler.sol b/contracts/src/arbitration/devtools/DisputeResolverRuler.sol index 96bf21001..cda344262 100644 --- a/contracts/src/arbitration/devtools/DisputeResolverRuler.sol +++ b/contracts/src/arbitration/devtools/DisputeResolverRuler.sol @@ -1,10 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] - import {DisputeResolver, IArbitratorV2, IDisputeTemplateRegistry} from "../arbitrables/DisputeResolver.sol"; pragma solidity 0.8.24; diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol b/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol index ef4591abd..f9696004d 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {DisputeKitClassicBase, KlerosCore} from "./DisputeKitClassicBase.sol"; diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol b/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol index b6865d9f7..3b06a1891 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {KlerosCore, KlerosCoreBase, IDisputeKit, ISortitionModule} from "../KlerosCore.sol"; diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol b/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol index 2318f1dfe..c3788c432 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {DisputeKitClassicBase, KlerosCore} from "./DisputeKitClassicBase.sol"; @@ -115,4 +109,4 @@ contract DisputeKitGated is DisputeKitClassicBase { return IBalanceHolder(tokenGate).balanceOf(_juror) > 0; } } -} \ No newline at end of file +} diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol b/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol index 0c6d98d5e..d406a2400 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import {DisputeKitClassicBase, KlerosCore} from "./DisputeKitClassicBase.sol"; diff --git a/contracts/src/arbitration/evidence/EvidenceModule.sol b/contracts/src/arbitration/evidence/EvidenceModule.sol index 21405bc6d..f0bfb4bdb 100644 --- a/contracts/src/arbitration/evidence/EvidenceModule.sol +++ b/contracts/src/arbitration/evidence/EvidenceModule.sol @@ -1,12 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@jaybuidl, @fnanni-0] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] -/// @custom:tools: [] - pragma solidity 0.8.24; import "../interfaces/IArbitratorV2.sol"; diff --git a/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol b/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol index f8c4f2a55..f3d6c3a05 100644 --- a/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol +++ b/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol @@ -1,12 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@fnanni-0] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] -/// @custom:tools: [] - pragma solidity 0.8.24; // TODO: standard interfaces should be placed in a separated repo (?) diff --git a/contracts/src/arbitration/interfaces/IDisputeKit.sol b/contracts/src/arbitration/interfaces/IDisputeKit.sol index 32e0bb7fb..f0b3d4d90 100644 --- a/contracts/src/arbitration/interfaces/IDisputeKit.sol +++ b/contracts/src/arbitration/interfaces/IDisputeKit.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1, @jaybuidl] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "./IArbitratorV2.sol"; diff --git a/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol b/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol new file mode 100644 index 000000000..633204a64 --- /dev/null +++ b/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; + +import {ISortitionModule} from "../interfaces/ISortitionModule.sol"; + +interface IKlerosCore { + function sortitionModule() external view returns (ISortitionModule); +} + +/// @title KlerosCoreSnapshotProxy +/// Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting. +contract KlerosCoreSnapshotProxy { + // ************************************* // + // * State Modifiers * // + // ************************************* // + + IKlerosCore public core; + address public governor; + string public constant name = "Staked Pinakion"; + string public constant symbol = "stPNK"; + uint8 public constant decimals = 18; + + // ************************************* // + // * Modifiers * // + // ************************************* // + + modifier onlyByGovernor() { + require(governor == msg.sender, "Access not allowed: Governor only."); + _; + } + + // ************************************* // + // * Constructor * // + // ************************************* // + + /// @dev Constructor + /// @param _governor The governor of the contract. + /// @param _core KlerosCore to read the balance from. + constructor(address _governor, IKlerosCore _core) { + governor = _governor; + core = _core; + } + + // ************************************* // + // * Governance * // + // ************************************* // + + /// @dev Changes the `governor` storage variable. + /// @param _governor The new value for the `governor` storage variable. + function changeGovernor(address _governor) external onlyByGovernor { + governor = _governor; + } + + /// @dev Changes the `core` storage variable. + /// @param _core The new value for the `core` storage variable. + function changeCore(IKlerosCore _core) external onlyByGovernor { + core = _core; + } + + // ************************************* // + // * Public Views * // + // ************************************* // + + /// @dev Returns the amount of PNK staked in KlerosV2 for a particular address. + /// Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID. + /// @param _account The address to query. + /// @return totalStaked Total amount staked in V2 by the address. + function balanceOf(address _account) external view returns (uint256 totalStaked) { + (totalStaked, , , ) = core.sortitionModule().getJurorBalance(_account, 0); + } +} diff --git a/contracts/src/gateway/ForeignGateway.sol b/contracts/src/gateway/ForeignGateway.sol index 81649b072..2617474ff 100644 --- a/contracts/src/gateway/ForeignGateway.sol +++ b/contracts/src/gateway/ForeignGateway.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@jaybuidl, @shotaronowhere, @shalzz] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "./interfaces/IForeignGateway.sol"; diff --git a/contracts/src/gateway/HomeGateway.sol b/contracts/src/gateway/HomeGateway.sol index ade0de2e6..3a31064c3 100644 --- a/contracts/src/gateway/HomeGateway.sol +++ b/contracts/src/gateway/HomeGateway.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@jaybuidl, @shotaronowhere, @shalzz] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "./interfaces/IForeignGateway.sol"; diff --git a/contracts/src/gateway/interfaces/IForeignGateway.sol b/contracts/src/gateway/interfaces/IForeignGateway.sol index 163e3b783..599684d0f 100644 --- a/contracts/src/gateway/interfaces/IForeignGateway.sol +++ b/contracts/src/gateway/interfaces/IForeignGateway.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@jaybuidl, @shotaronowhere, @shalzz] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "../../arbitration/interfaces/IArbitratorV2.sol"; diff --git a/contracts/src/gateway/interfaces/IHomeGateway.sol b/contracts/src/gateway/interfaces/IHomeGateway.sol index 28a01fbfa..ad20fb7e0 100644 --- a/contracts/src/gateway/interfaces/IHomeGateway.sol +++ b/contracts/src/gateway/interfaces/IHomeGateway.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@jaybuidl, @shotaronowhere, @shalzz] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; diff --git a/contracts/src/kleros-v1/interfaces/IArbitrableV1.sol b/contracts/src/kleros-v1/interfaces/IArbitrableV1.sol index a4bf24fe3..55a598764 100644 --- a/contracts/src/kleros-v1/interfaces/IArbitrableV1.sol +++ b/contracts/src/kleros-v1/interfaces/IArbitrableV1.sol @@ -1,10 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@ferittuncer, @hbarcelos, @clesaege] -/// @custom:reviewers: [@remedcu] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] pragma solidity 0.8.24; import "./IArbitratorV1.sol"; diff --git a/contracts/src/kleros-v1/interfaces/IArbitratorV1.sol b/contracts/src/kleros-v1/interfaces/IArbitratorV1.sol index bdd82daa1..cf4fbe44e 100644 --- a/contracts/src/kleros-v1/interfaces/IArbitratorV1.sol +++ b/contracts/src/kleros-v1/interfaces/IArbitratorV1.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@ferittuncer, @hbarcelos, @clesaege] -/// @custom:reviewers: [@remedcu] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "./IArbitrableV1.sol"; diff --git a/contracts/src/libraries/SortitionSumTreeFactory.sol b/contracts/src/libraries/SortitionSumTreeFactory.sol index eab7b1ab8..b40f3cc84 100644 --- a/contracts/src/libraries/SortitionSumTreeFactory.sol +++ b/contracts/src/libraries/SortitionSumTreeFactory.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@epiqueras, @unknownunknown1] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; /// @title SortitionSumTreeFactory diff --git a/contracts/src/test/KlerosCoreMock.sol b/contracts/src/test/KlerosCoreMock.sol index 76bb75f2c..25eea2da3 100644 --- a/contracts/src/test/KlerosCoreMock.sol +++ b/contracts/src/test/KlerosCoreMock.sol @@ -1,11 +1,5 @@ // SPDX-License-Identifier: MIT -/// @custom:authors: [@unknownunknown1] -/// @custom:reviewers: [] -/// @custom:auditors: [] -/// @custom:bounties: [] -/// @custom:deployments: [] - pragma solidity 0.8.24; import "../arbitration/KlerosCore.sol"; diff --git a/contracts/test/foundry/KlerosCore.t.sol b/contracts/test/foundry/KlerosCore.t.sol index 56e33c9c5..66d2f22cd 100644 --- a/contracts/test/foundry/KlerosCore.t.sol +++ b/contracts/test/foundry/KlerosCore.t.sol @@ -3,9 +3,10 @@ pragma solidity 0.8.24; import {Test} from "forge-std/Test.sol"; import {console} from "forge-std/console.sol"; // Import the console for logging -import {KlerosCoreMock, KlerosCoreBase, IArbitratorV2} from "../../src/test/KlerosCoreMock.sol"; +import {KlerosCoreMock, KlerosCoreBase} from "../../src/test/KlerosCoreMock.sol"; +import {IArbitratorV2} from "../../src/arbitration/KlerosCoreBase.sol"; import {IDisputeKit} from "../../src/arbitration/interfaces/IDisputeKit.sol"; -import {DisputeKitClassic} from "../../src/arbitration/dispute-kits/DisputeKitClassic.sol"; +import {DisputeKitClassic, DisputeKitClassicBase} from "../../src/arbitration/dispute-kits/DisputeKitClassic.sol"; import {DisputeKitSybilResistant} from "../../src/arbitration/dispute-kits/DisputeKitSybilResistant.sol"; import {ISortitionModule} from "../../src/arbitration/interfaces/ISortitionModule.sol"; import {SortitionModuleMock, SortitionModuleBase} from "../../src/test/SortitionModuleMock.sol"; @@ -16,6 +17,7 @@ import {TestERC20} from "../../src/token/TestERC20.sol"; import {ArbitrableExample, IArbitrableV2} from "../../src/arbitration/arbitrables/ArbitrableExample.sol"; import {DisputeTemplateRegistry} from "../../src/arbitration/DisputeTemplateRegistry.sol"; import "../../src/libraries/Constants.sol"; +import {IKlerosCore, KlerosCoreSnapshotProxy} from "../../src/snapshot-proxy/KlerosCoreSnapshotProxy.sol"; contract KlerosCoreTest is Test { event Initialized(uint64 version); @@ -1278,6 +1280,33 @@ contract KlerosCoreTest is Test { core.setStakeBySortitionModule(staker1, GENERAL_COURT, 1000, false); } + function test_setStake_snapshotProxyCheck() public { + vm.prank(staker1); + core.setStake(GENERAL_COURT, 12346); + + KlerosCoreSnapshotProxy snapshotProxy = new KlerosCoreSnapshotProxy(governor, IKlerosCore(address(core))); + assertEq(snapshotProxy.name(), "Staked Pinakion", "Wrong name of the proxy token"); + assertEq(snapshotProxy.symbol(), "stPNK", "Wrong symbol of the proxy token"); + assertEq(snapshotProxy.decimals(), 18, "Wrong decimals of the proxy token"); + assertEq(snapshotProxy.governor(), msg.sender, "Wrong governor"); + assertEq(address(snapshotProxy.core()), address(core), "Wrong core in snapshot proxy"); + assertEq(snapshotProxy.balanceOf(staker1), 12346, "Wrong stPNK balance"); + + vm.prank(other); + vm.expectRevert(bytes("Access not allowed: Governor only.")); + snapshotProxy.changeCore(IKlerosCore(other)); + vm.prank(governor); + snapshotProxy.changeCore(IKlerosCore(other)); + assertEq(address(snapshotProxy.core()), other, "Wrong core in snapshot proxy after change"); + + vm.prank(other); + vm.expectRevert(bytes("Access not allowed: Governor only.")); + snapshotProxy.changeGovernor(other); + vm.prank(governor); + snapshotProxy.changeGovernor(other); + assertEq(snapshotProxy.governor(), other, "Wrong governor after change"); + } + // *************************************** // // * Disputes * // // *************************************** // @@ -1326,7 +1355,7 @@ contract KlerosCoreTest is Test { uint256 nbChoices = 2; vm.prank(disputer); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.DisputeCreation(disputeID, nbChoices, newExtraData); + emit DisputeKitClassicBase.DisputeCreation(disputeID, nbChoices, newExtraData); vm.expectEmit(true, true, true, true); emit IArbitratorV2.DisputeCreation(disputeID, arbitrable); arbitrable.createDispute{value: 0.04 ether}("Action"); @@ -1592,7 +1621,7 @@ contract KlerosCoreTest is Test { vm.prank(staker1); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.CommitCast(disputeID, staker1, voteIDs, commit); + emit DisputeKitClassicBase.CommitCast(disputeID, staker1, voteIDs, commit); disputeKit.castCommit(disputeID, voteIDs, commit); (, , , uint256 totalCommited, uint256 nbVoters, uint256 choiceCount) = disputeKit.getRoundInfo(disputeID, 0, 0); @@ -1608,7 +1637,7 @@ contract KlerosCoreTest is Test { vm.prank(staker1); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.CommitCast(disputeID, staker1, voteIDs, commit); + emit DisputeKitClassicBase.CommitCast(disputeID, staker1, voteIDs, commit); disputeKit.castCommit(disputeID, voteIDs, commit); (, , , totalCommited, nbVoters, choiceCount) = disputeKit.getRoundInfo(disputeID, 0, 0); @@ -1913,7 +1942,7 @@ contract KlerosCoreTest is Test { vm.prank(crowdfunder1); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.Contribution(disputeID, 0, 1, crowdfunder1, 0.21 ether); + emit DisputeKitClassicBase.Contribution(disputeID, 0, 1, crowdfunder1, 0.21 ether); disputeKit.fundAppeal{value: 0.21 ether}(disputeID, 1); // Fund the losing choice. Total cost will be 0.63 (0.21 + 0.21 * (20000/10000)) assertEq(crowdfunder1.balance, 9.79 ether, "Wrong balance of the crowdfunder"); @@ -1922,9 +1951,9 @@ contract KlerosCoreTest is Test { vm.prank(crowdfunder1); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.Contribution(disputeID, 0, 1, crowdfunder1, 0.42 ether); + emit DisputeKitClassicBase.Contribution(disputeID, 0, 1, crowdfunder1, 0.42 ether); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.ChoiceFunded(disputeID, 0, 1); + emit DisputeKitClassicBase.ChoiceFunded(disputeID, 0, 1); disputeKit.fundAppeal{value: 5 ether}(disputeID, 1); // Deliberately overpay to check reimburse assertEq(crowdfunder1.balance, 9.37 ether, "Wrong balance of the crowdfunder"); @@ -2117,7 +2146,7 @@ contract KlerosCoreTest is Test { vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitJump(disputeID, 1, newDkID, DISPUTE_KIT_CLASSIC); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.DisputeCreation(disputeID, 2, newExtraData); + emit DisputeKitClassicBase.DisputeCreation(disputeID, 2, newExtraData); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.AppealDecision(disputeID, arbitrable); vm.expectEmit(true, true, true, true); @@ -2692,11 +2721,11 @@ contract KlerosCoreTest is Test { assertEq(address(disputeKit).balance, 1.04 ether, "Wrong balance of the DK"); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.Withdrawal(disputeID, 0, 1, crowdfunder1, 0.63 ether); + emit DisputeKitClassicBase.Withdrawal(disputeID, 0, 1, crowdfunder1, 0.63 ether); disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 0, 1); vm.expectEmit(true, true, true, true); - emit DisputeKitClassic.Withdrawal(disputeID, 0, 2, crowdfunder2, 0.41 ether); + emit DisputeKitClassicBase.Withdrawal(disputeID, 0, 2, crowdfunder2, 0.41 ether); disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 0, 2); assertEq(crowdfunder1.balance, 10 ether, "Wrong balance of the crowdfunder1"); diff --git a/kleros-app/README.md b/kleros-app/README.md index 1db6aeafe..0e4c6818d 100644 --- a/kleros-app/README.md +++ b/kleros-app/README.md @@ -27,14 +27,17 @@ import { WagmiProvider } from 'wagmi' import { config } from './config' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { AtlasProvider, Products } from "@kleros/kleros-app"; +import { useConfig } from 'wagmi' const queryClient = new QueryClient() function App() { + const wagmiConfig = useConfig() + return - + ... diff --git a/kleros-app/package.json b/kleros-app/package.json index 62df10e1a..2c3de6e35 100644 --- a/kleros-app/package.json +++ b/kleros-app/package.json @@ -14,7 +14,7 @@ ], "type": "module", "volta": { - "node": "20.18.2" + "node": "20.18.3" }, "publishConfig": { "access": "public", @@ -49,7 +49,8 @@ "typescript": "^5.6.3", "vite": "^5.4.11", "vite-plugin-dts": "^4.3.0", - "vite-plugin-node-polyfills": "^0.22.0" + "vite-plugin-node-polyfills": "^0.23.0", + "wagmi": "^2.14.0" }, "dependencies": { "jose": "^5.9.6" @@ -61,6 +62,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "viem": "^2.21.42", - "wagmi": "^2.13.5" + "wagmi": "^2.14.0" } } diff --git a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx index 1701faf47..ee50e3c31 100644 --- a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx +++ b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx @@ -2,7 +2,7 @@ import React, { useMemo, createContext, useContext, useState, useCallback, useEf import { useQuery, useQueryClient } from "@tanstack/react-query"; import { GraphQLClient } from "graphql-request"; import { decodeJwt } from "jose"; -import { useAccount, useChainId, useSignMessage } from "wagmi"; +import { useAccount, useChainId, useSignMessage, type Config } from "wagmi"; import { createMessage, getNonce, @@ -53,11 +53,12 @@ const Context = createContext(undefined); interface AtlasConfig { uri: string; product: Products; + wagmiConfig: Config; } export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.ReactNode }> = ({ children, config }) => { - const { address } = useAccount(); - const chainId = useChainId(); + const { address } = useAccount({ config: config.wagmiConfig }); + const chainId = useChainId({ config: config.wagmiConfig }); const queryClient = useQueryClient(); const [authToken, setAuthToken] = useSessionStorage("authToken", undefined); @@ -66,7 +67,7 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea const [isUpdatingUser, setIsUpdatingUser] = useState(false); const [isVerified, setIsVerified] = useState(false); const [isUploadingFile, setIsUploadingFile] = useState(false); - const { signMessageAsync } = useSignMessage(); + const { signMessageAsync } = useSignMessage({ config: config.wagmiConfig }); const atlasGqlClient = useMemo(() => { const headers = authToken diff --git a/kleros-sdk/package.json b/kleros-sdk/package.json index eecaef5c2..86addead6 100644 --- a/kleros-sdk/package.json +++ b/kleros-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@kleros/kleros-sdk", - "version": "2.2.0", + "version": "2.3.0", "description": "SDK for Kleros version 2", "repository": "git@github.com:kleros/kleros-v2.git", "homepage": "https://github.com/kleros/kleros-v2/tree/master/kleros-sdk#readme", @@ -15,7 +15,7 @@ ], "type": "commonjs", "volta": { - "node": "20.18.2" + "node": "20.18.3" }, "publishConfig": { "access": "public", @@ -43,7 +43,7 @@ "vitest": "^1.6.0" }, "dependencies": { - "@reality.eth/reality-eth-lib": "^3.2.44", + "@reality.eth/reality-eth-lib": "^3.2.60", "@urql/core": "^5.0.8", "mustache": "^4.2.0", "zod": "^3.23.8" diff --git a/kleros-sdk/src/dataMappings/utils/index.ts b/kleros-sdk/src/dataMappings/utils/index.ts index bacf46150..1c9d85d45 100644 --- a/kleros-sdk/src/dataMappings/utils/index.ts +++ b/kleros-sdk/src/dataMappings/utils/index.ts @@ -1,3 +1,6 @@ export * from "./populateTemplate"; export * from "./retrieveVariables"; export * from "./disputeDetailsTypes"; + +export const isUndefined = (maybeObject: any): maybeObject is undefined | null => + typeof maybeObject === "undefined" || maybeObject === null; diff --git a/kleros-sdk/src/dataMappings/utils/populateTemplate.ts b/kleros-sdk/src/dataMappings/utils/populateTemplate.ts index a70668ab7..68ae983ec 100644 --- a/kleros-sdk/src/dataMappings/utils/populateTemplate.ts +++ b/kleros-sdk/src/dataMappings/utils/populateTemplate.ts @@ -11,11 +11,23 @@ export const populateTemplate = (mustacheTemplate: string, data: any): DisputeDe throw validation.error; } - // Filter out any existing answer with id 0 and add our standard Refuse to Arbitrate option - (dispute as DisputeDetails).answers = [ - RefuseToArbitrateAnswer, - ...((dispute as DisputeDetails).answers.filter((answer) => answer.id && BigInt(answer.id) !== BigInt(0)) || []), - ]; + return findAndUpdateRTA(dispute); +}; + +// Filter out any existing answer with id 0 and add customised Refuse to Arbitrate option +const findAndUpdateRTA = (dispute: DisputeDetails) => { + const templateRTAIndex = (dispute as DisputeDetails).answers.findIndex( + (answer) => answer.id && BigInt(answer.id) === BigInt(0) + ); + + if (templateRTAIndex !== -1) { + dispute.answers[templateRTAIndex] = { + ...RefuseToArbitrateAnswer, + description: dispute.answers[templateRTAIndex].description ?? RefuseToArbitrateAnswer.description, + }; + } else { + dispute.answers = [RefuseToArbitrateAnswer, ...dispute.answers]; + } return dispute; }; diff --git a/kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts b/kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts index 2f5520ef7..655cad0c5 100644 --- a/kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts +++ b/kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts @@ -2,6 +2,7 @@ import mustache from "mustache"; import retrieveVariables from "./retrieveVariables"; import { ActionMapping } from "./actionTypes"; import { InvalidContextError } from "../../errors"; +import { isUndefined } from "."; export function replacePlaceholdersWithValues( mapping: ActionMapping, @@ -35,7 +36,8 @@ const validateContext = (template: string, context: Record) => const variables = retrieveVariables(template); variables.forEach((variable) => { - if (!context[variable]) throw new InvalidContextError(`Expected key "${variable}" to be provided in context.`); + if (isUndefined(context[variable])) + throw new InvalidContextError(`Expected key "${variable}" to be provided in context.`); }); return true; }; diff --git a/kleros-sdk/test/getDispute.test.ts b/kleros-sdk/test/getDispute.test.ts index 0d1fadc0f..553a0ec27 100644 --- a/kleros-sdk/test/getDispute.test.ts +++ b/kleros-sdk/test/getDispute.test.ts @@ -105,7 +105,14 @@ describe("getDispute", () => { expect(result?.answers[2].id).toBe("0x2"); }); - it("should overwrite existing answer with id 0x0 or 0x00", async () => { + it("should only overwrite existing answer with id 0x0 or 0x00's title and not overwrite description", async () => { + const customRTAAnswer = { + id: "0x0", + title: "Custom Refuse Title", + description: "Custom Refuse Description", + reserved: true, + }; + // Test with 0x0 const mockTemplate0x0 = { disputeTemplate: { @@ -114,12 +121,7 @@ describe("getDispute", () => { description: "Test Description", question: "Test Question", answers: [ - { - id: "0x0", - title: "Custom Refuse Title", - description: "Custom Refuse Description", - reserved: true, - }, + customRTAAnswer, { id: "0x1", title: "Yes", @@ -145,7 +147,8 @@ describe("getDispute", () => { }); expect(result?.answers).toHaveLength(2); - expect(result?.answers[0]).toEqual(standardRefuseToArbitrateAnswer); + expect(result?.answers[0].title).toEqual(standardRefuseToArbitrateAnswer.title); + expect(result?.answers[0].description).toEqual(customRTAAnswer.description); expect(result?.answers[1].id).toBe("0x1"); // Test with 0x00 @@ -156,12 +159,7 @@ describe("getDispute", () => { description: "Test Description", question: "Test Question", answers: [ - { - id: "0x00", - title: "Custom Refuse Title", - description: "Custom Refuse Description", - reserved: true, - }, + customRTAAnswer, { id: "0x1", title: "Yes", @@ -186,7 +184,8 @@ describe("getDispute", () => { }); expect(result?.answers).toHaveLength(2); - expect(result?.answers[0]).toEqual(standardRefuseToArbitrateAnswer); + expect(result?.answers[0].title).toEqual(standardRefuseToArbitrateAnswer.title); + expect(result?.answers[0].description).toEqual(customRTAAnswer.description); expect(result?.answers[1].id).toBe("0x1"); }); diff --git a/package.json b/package.json index 565153bae..7771cc586 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ ], "packageManager": "yarn@4.6.0", "volta": { - "node": "20.18.2", + "node": "20.18.3", "yarn": "4.6.0" }, "devDependencies": { @@ -57,10 +57,10 @@ "minimatch@npm:3.0.4": "npm:3.0.8", "minimatch@npm:^3.0.4": "npm:3.0.8", "nanoid^3.3.1": "npm:3.3.4", - "node-fetch": "npm:2.6.7", + "node-fetch": "npm:node-fetch@2.7.0", "underscore@npm^3.0.4": "npm:1.12.1", "eth-sig-util@npm:^1.4.2": "npm:3.0.0", - "fast-xml-parser": "npm:4.2.5", + "fast-xml-parser": "npm:fast-xml-parser@4.5.2", "@babel/traverse:^7.22.5": "npm:7.23.6", "yargs-unparser@npm:1.6.0": "npm:1.6.4", "dompurify@npm:^2.4.0": "npm:2.5.7", @@ -73,7 +73,8 @@ "@openzeppelin/contracts-upgradeable@npm:4.5.2": "npm:4.9.6", "@openzeppelin/contracts-upgradeable@npm:4.7.3": "npm:4.9.6", "@openzeppelin/contracts-upgradeable@npm:4.8.3": "npm:4.9.6", - "@openzeppelin/contracts-upgradeable@npm:4.9.3": "npm:4.9.6" + "@openzeppelin/contracts-upgradeable@npm:4.9.3": "npm:4.9.6", + "elliptic@npm:6.5.4": "npm:6.6.1" }, "scripts": { "check-prerequisites": "scripts/check-prerequisites.sh", diff --git a/services/graph-node/docker-compose.yml b/services/graph-node/docker-compose.yml index 7833b0780..8ae23ea68 100644 --- a/services/graph-node/docker-compose.yml +++ b/services/graph-node/docker-compose.yml @@ -25,7 +25,7 @@ services: GRAPH_LOG: info stop_grace_period: 5s ipfs: - image: ipfs/go-ipfs:v0.22.0 + image: ipfs/go-ipfs:v0.33.2 ports: - "5001:5001" volumes: diff --git a/subgraph/package.json b/subgraph/package.json index f655b6e86..638be7422 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -69,7 +69,7 @@ "stop-local-indexer": "docker compose -f ../services/graph-node/docker-compose.yml down && rm -rf ../services/graph-node/data" }, "volta": { - "node": "20.18.2" + "node": "20.18.3" }, "dependencies": { "@graphprotocol/graph-ts": "^0.37.0" diff --git a/web-devtools/.gitignore b/web-devtools/.gitignore index dab706c2e..5aa6001da 100644 --- a/web-devtools/.gitignore +++ b/web-devtools/.gitignore @@ -45,3 +45,8 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +.env* +.flaskenv* +!.env.project +!.env.vault \ No newline at end of file diff --git a/web-devtools/package.json b/web-devtools/package.json index 036de490a..911c78654 100644 --- a/web-devtools/package.json +++ b/web-devtools/package.json @@ -8,8 +8,8 @@ "license": "MIT", "type": "module", "volta": { - "node": "20.18.2", - "yarn": "4.5.1" + "node": "20.18.3", + "yarn": "4.6.0" }, "scripts": { "clean": "rimraf .next src/graphql-generated src/hooks/contracts/generated.ts", @@ -50,14 +50,15 @@ "@kleros/kleros-sdk": "workspace:^", "@kleros/kleros-v2-contracts": "workspace:^", "@kleros/ui-components-library": "^2.20.0", + "@reown/appkit": "^1.6.5", + "@reown/appkit-adapter-wagmi": "^1.6.5", "@tanstack/react-query": "^5.61.0", "@wagmi/connectors": "^5.5.0", - "@wagmi/core": "^2.15.0", - "@web3modal/wagmi": "^4.2.3", - "@yornaath/batshit": "^0.9.0", + "@wagmi/core": "^2.16.3", + "@yornaath/batshit": "^0.10.0", "graphql": "^16.9.0", "graphql-request": "^7.1.2", - "next": "14.2.18", + "next": "14.2.21", "react": "^18.3.1", "react-dom": "^18.3.1", "react-is": "^18.3.1", @@ -67,8 +68,8 @@ "react-use": "^17.5.1", "styled-components": "^5.3.3", "typewriter-effect": "^2.21.0", - "vanilla-jsoneditor": "^0.21.6", + "vanilla-jsoneditor": "^0.23.0", "viem": "^2.21.50", - "wagmi": "^2.13.5" + "wagmi": "^2.14.10" } } diff --git a/web-devtools/src/app/(main)/dispute-template/page.tsx b/web-devtools/src/app/(main)/dispute-template/page.tsx index ff9802520..e1522060b 100644 --- a/web-devtools/src/app/(main)/dispute-template/page.tsx +++ b/web-devtools/src/app/(main)/dispute-template/page.tsx @@ -26,6 +26,8 @@ import ReactMarkdown from "components/ReactMarkdown"; import FetchDisputeRequestInput, { DisputeRequest } from "./FetchDisputeRequestInput"; import FetchFromIDInput from "./FetchFromIdInput"; import CustomContextInputs from "./CustomContextInputs"; +import { debounceErrorToast } from "utils/debounceErrorToast"; +import { isEmpty } from "utils/isEmpty"; const Container = styled.div` height: auto; @@ -193,12 +195,14 @@ const DisputeTemplateView = () => { if (customContext) initialContext = { ...initialContext, ...customContext }; const fetchData = async () => { + if (isEmpty(disputeTemplateInput)) return; try { const data = dataMappingsInput ? await executeActions(JSON.parse(dataMappingsInput), initialContext) : {}; const finalDisputeDetails = populateTemplate(disputeTemplateInput, data); setDisputeDetails(finalDisputeDetails); - } catch (e) { + } catch (e: any) { console.error(e); + debounceErrorToast(e?.message); setDisputeDetails(undefined); } finally { setLoading(false); diff --git a/web-devtools/src/components/ConnectWallet/index.tsx b/web-devtools/src/components/ConnectWallet/index.tsx index aced96c9f..ff9364429 100644 --- a/web-devtools/src/components/ConnectWallet/index.tsx +++ b/web-devtools/src/components/ConnectWallet/index.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from "react"; -import { useWeb3Modal, useWeb3ModalState } from "@web3modal/wagmi/react"; +import { useAppKit, useAppKitState } from "@reown/appkit/react"; import { useAccount, useSwitchChain } from "wagmi"; import { Button } from "@kleros/ui-components-library"; @@ -33,8 +33,8 @@ export const SwitchChainButton: React.FC<{ className?: string }> = ({ className }; const ConnectButton: React.FC<{ className?: string }> = ({ className }) => { - const { open } = useWeb3Modal(); - const { open: isOpen } = useWeb3ModalState(); + const { open } = useAppKit(); + const { open: isOpen } = useAppKitState(); return (