Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 22 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,68 @@ on:
paths:
- 'contracts/**'
- 'test/**'
- 'scripts/**'
- 'hardhat.config.ts'
- 'package.json'
- 'package-lock.json'
- 'script/**'
- 'foundry.toml'
- '.github/workflows/ci.yml'
pull_request:
branches: ['*']
paths:
- 'contracts/**'
- 'test/**'
- 'scripts/**'
- 'hardhat.config.ts'
- 'package.json'
- 'package-lock.json'
- 'script/**'
- 'foundry.toml'
- '.github/workflows/ci.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
NODE_VERSION: '24'

jobs:
lint-and-format:
name: Lint & Format
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@v4

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- run: npm ci --legacy-peer-deps
- name: Install dependencies
run: forge install --no-git foundry-rs/forge-std OpenZeppelin/openzeppelin-contracts@v5.4.0 FhenixProtocol/cofhe-contracts FhenixProtocol/cofhe-mock-contracts OpenZeppelin/openzeppelin-foundry-upgrades

- name: Check formatting
run: npm run format:check

- name: Lint Solidity
run: npm run lint
run: forge fmt --check

compile:
name: Compile Contracts
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@v4

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- run: npm ci --legacy-peer-deps
- name: Install dependencies
run: forge install --no-git foundry-rs/forge-std OpenZeppelin/openzeppelin-contracts@v5.4.0 FhenixProtocol/cofhe-contracts FhenixProtocol/cofhe-mock-contracts OpenZeppelin/openzeppelin-foundry-upgrades

- name: Compile contracts
run: npm run compile
run: forge build --sizes

test:
name: Test Contracts
runs-on: ubuntu-latest
needs: compile
timeout-minutes: 15
env:
MOCHA_TIMEOUT: '120000'
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@v4

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- run: npm ci --legacy-peer-deps
- name: Install dependencies
run: forge install --no-git foundry-rs/forge-std OpenZeppelin/openzeppelin-contracts@v5.4.0 FhenixProtocol/cofhe-contracts FhenixProtocol/cofhe-mock-contracts OpenZeppelin/openzeppelin-foundry-upgrades

- name: Run tests
run: npm test
run: forge test -vvv
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
node_modules/
cache/
cache_forge/
artifacts/
typechain-types/
coverage/
coverage.json
.env
deployments/*.json
!deployments/.gitkeep

# Foundry
out/
broadcast/
lib/
1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

16 changes: 0 additions & 16 deletions .prettierrc

This file was deleted.

10 changes: 0 additions & 10 deletions .solhint.json

This file was deleted.

106 changes: 41 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,66 @@
# ReineiraOS Code
## Foundry

[![Platform](https://img.shields.io/badge/ReineiraOS-v0.1-blue)](https://reineira.xyz)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

AI-assisted plugin development for ReineiraOS. Build condition resolvers and insurance policies with Claude Code.
Foundry consists of:

> **Platform 0.1** — Generates contracts compatible with ReineiraOS v0.1 interfaces. Check `reineira.json` for version details.
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Setup
## Documentation

```bash
git clone https://github.com/ReineiraOS/reineira-code.git
cd reineira-code
npm install --legacy-peer-deps
cp .env.example .env
# Add your private key and RPC URL to .env
```
https://book.getfoundry.sh/

## Usage

Open in an editor with Claude Code. Use slash commands:

| Command | What it does |
| ---------------- | ------------------------------------------------------ |
| `/new-resolver` | Build a condition resolver from a description |
| `/new-policy` | Build an insurance policy with FHE from a description |
| `/deploy` | Deploy any contract to Arbitrum Sepolia |
| `/test` | Run tests, diagnose and fix failures |
| `/audit` | Security audit against the protocol checklist |
| `/integrate` | Generate SDK code to attach your contract to an escrow |
| `/scaffold-test` | Generate tests for an existing contract |
| `/verify` | Verify a deployed contract on Arbiscan |

### Example
### Build

```shell
$ forge build
```
/new-resolver A resolver that verifies PayPal payment via zkTLS proof from Reclaim Protocol
```

Claude Code generates the Solidity contract, tests, and deployment script — all pre-configured for the ReineiraOS protocol.

## The ecosystem
### Test

| Repo | What you do there | Platform |
| ------------------------------------------------------------------ | ---------------------------------------------------------- | -------- |
| [reineira-atlas](https://github.com/ReineiraOS/reineira-atlas) | Run the startup — strategy, ops, growth, compliance, pitch | 0.1 |
| **reineira-code** (this repo) | Build smart contracts — resolvers, policies, tests, deploy | 0.1 |
| [platform-modules](https://github.com/ReineiraOS/platform-modules) | Ship the product — backend, platform app, payment link | 0.1 |
```shell
$ forge test
```

All repos declare their platform compatibility in `reineira.json`. When the platform version bumps, breaking contract interface changes may require upgrading.
### Format

## Manual workflow
```shell
$ forge fmt
```

```bash
# Compile
npm run compile
### Gas Snapshots

# Test
npm test
```shell
$ forge snapshot
```

# Deploy
CONTRACT_NAME=MyResolver npm run deploy
### Anvil

# Verify on Arbiscan
npx hardhat verify --network arbitrumSepolia <address>
```shell
$ anvil
```

## Compatibility
### Deploy

| Component | Requirement |
| --------- | ----------------------- |
| Platform | ReineiraOS 0.1 |
| Solidity | ^0.8.24 |
| Hardhat | ~2.26.x |
| SDK | @reineira-os/sdk ^0.1.0 |
| cofhejs | ^0.3.1 |
| Node.js | 18+ |
```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

## Documentation
### Cast

- [ReineiraOS Docs](https://reineira.xyz/docs)
- [Quick Start](https://reineira.xyz/docs/getting-started/quick-start)
- [Condition Plugins](https://reineira.xyz/docs/develop/condition-plugins)
- [Insurance Policies](https://reineira.xyz/docs/develop/insurance-policies)
- [Telegram](https://t.me/ReineiraOS)
```shell
$ cast <subcommand>
```

## License
### Help

MIT
```shell
$ forge --help
$ anvil --help
$ cast --help
```
20 changes: 10 additions & 10 deletions contracts/interfaces/IConditionResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ pragma solidity ^0.8.24;
/// @notice Interface for escrow release condition plugins.
/// @dev Implement this to control when a ConfidentialEscrow releases funds.
interface IConditionResolver {
/// @notice Check if the release condition for an escrow is met.
/// @dev Called on every redeem attempt. MUST be a view function.
/// @param escrowId The sequential escrow identifier.
/// @return True if the escrow should release funds.
function isConditionMet(uint256 escrowId) external view returns (bool);
/// @notice Check if the release condition for an escrow is met.
/// @dev Called on every redeem attempt. MUST be a view function.
/// @param escrowId The sequential escrow identifier.
/// @return True if the escrow should release funds.
function isConditionMet(uint256 escrowId) external view returns (bool);

/// @notice Initialize condition configuration for a new escrow.
/// @dev Called atomically during ConfidentialEscrow.create().
/// @param escrowId The sequential escrow identifier.
/// @param data ABI-encoded configuration specific to this resolver.
function onConditionSet(uint256 escrowId, bytes calldata data) external;
/// @notice Initialize condition configuration for a new escrow.
/// @dev Called atomically during ConfidentialEscrow.create().
/// @param escrowId The sequential escrow identifier.
/// @param data ABI-encoded configuration specific to this resolver.
function onConditionSet(uint256 escrowId, bytes calldata data) external;
}
34 changes: 17 additions & 17 deletions contracts/interfaces/IUnderwriterPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import {euint64, ebool} from "@fhenixprotocol/cofhe-contracts/FHE.sol";
/// @dev Implement this to define risk evaluation and dispute resolution.
/// Return values are FHE-encrypted — the protocol operates on ciphertexts.
interface IUnderwriterPolicy {
/// @notice Initialize policy-specific data for a new coverage.
/// @param coverageId The coverage identifier.
/// @param data ABI-encoded policy configuration.
function onPolicySet(uint256 coverageId, bytes calldata data) external;
/// @notice Initialize policy-specific data for a new coverage.
/// @param coverageId The coverage identifier.
/// @param data ABI-encoded policy configuration.
function onPolicySet(uint256 coverageId, bytes calldata data) external;

/// @notice Evaluate risk and return an encrypted risk score.
/// @dev Score is in basis points (0-10000). 100 bps = 1% premium.
/// MUST call FHE.allowThis() and FHE.allow(value, msg.sender) on return value.
/// @param escrowId The escrow being insured.
/// @param riskProof Arbitrary proof data for risk evaluation.
/// @return riskScore Encrypted risk score in basis points.
function evaluateRisk(uint256 escrowId, bytes calldata riskProof) external returns (euint64 riskScore);
/// @notice Evaluate risk and return an encrypted risk score.
/// @dev Score is in basis points (0-10000). 100 bps = 1% premium.
/// MUST call FHE.allowThis() and FHE.allow(value, msg.sender) on return value.
/// @param escrowId The escrow being insured.
/// @param riskProof Arbitrary proof data for risk evaluation.
/// @return riskScore Encrypted risk score in basis points.
function evaluateRisk(uint256 escrowId, bytes calldata riskProof) external returns (euint64 riskScore);

/// @notice Judge a dispute and return an encrypted verdict.
/// @dev MUST call FHE.allowThis() and FHE.allow(value, msg.sender) on return value.
/// @param coverageId The coverage being disputed.
/// @param disputeProof Arbitrary proof data from the claimant.
/// @return valid Encrypted boolean — true if the claim is legitimate.
function judge(uint256 coverageId, bytes calldata disputeProof) external returns (ebool valid);
/// @notice Judge a dispute and return an encrypted verdict.
/// @dev MUST call FHE.allowThis() and FHE.allow(value, msg.sender) on return value.
/// @param coverageId The coverage being disputed.
/// @param disputeProof Arbitrary proof data from the claimant.
/// @return valid Encrypted boolean — true if the claim is legitimate.
function judge(uint256 coverageId, bytes calldata disputeProof) external returns (ebool valid);
}
Loading
Loading