Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d6963f
chore: refactor fee tests and deployment to take in vincent diamond o…
glitch003 Nov 11, 2025
3802e99
feat: deployed to base, deployment works
glitch003 Nov 11, 2025
84ce929
feat: basic lit action structure
glitch003 Nov 11, 2025
03a571b
feat: action deploy script
glitch003 Nov 11, 2025
4fe06ef
feat: check chainId, set hardcoded 5 min expiration
glitch003 Nov 11, 2025
aeb20ea
feat: issuedAt param
glitch003 Nov 11, 2025
40f4381
fix: sign owner attestation deployed and ipfs cid recorded
glitch003 Nov 11, 2025
cc9c61d
fix: forge fmt
glitch003 Nov 11, 2025
c62cb93
fix: regen lockfile
glitch003 Nov 11, 2025
ae023bc
fix: linting
glitch003 Nov 11, 2025
ca68994
fix: add signOwnerAttestation derived action address
glitch003 Nov 12, 2025
a417ff8
feat: first pass at tests - need to fix app creation
glitch003 Nov 12, 2025
1c148be
fix: tests get all the way to aave deposit
glitch003 Nov 12, 2025
09aba13
feat: adding script to set necessary vars on fee contract
glitch003 Nov 12, 2025
7c2a2fc
feat: add script to set required contract vars
glitch003 Nov 12, 2025
6a375ae
fix: depositing works, now working on withdraw part of test
glitch003 Nov 13, 2025
14bd0e6
fix: fixing lit action
glitch003 Nov 13, 2025
3a6d540
fix: withdraw works, but profit is too small. upping deposit amount …
glitch003 Nov 13, 2025
d7c0ec6
fix: action getAppById abi
glitch003 Nov 13, 2025
58bc65d
fix: lit action, and derive action wallet address after deployment
glitch003 Nov 13, 2025
688dcde
fix: on final withdrawal
glitch003 Nov 13, 2025
84da4a7
fix: the test works, yay
glitch003 Nov 13, 2025
1602484
chore: prep for platform fee withdrawal test
glitch003 Nov 13, 2025
ddd5405
fix: all tests pass
glitch003 Nov 13, 2025
6187578
fix: esbuild polyfill version, move lit-node-client into dependencies…
glitch003 Nov 13, 2025
2340ec2
chore: reorg contracts-sdk fees lit action stuff
glitch003 Nov 13, 2025
ff2f8e3
chore: docs update
glitch003 Nov 13, 2025
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
18 changes: 17 additions & 1 deletion packages/libs/contracts-sdk/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Deployment Configuration
VINCENT_DEPLOYMENT_RPC_URL=https://yellowstone-rpc.litprotocol.com/
# Required for Fee Contract Deployment
VINCENT_DEPLOYER_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

# Datil Production Network (used for both Vincent prod & dev)
DATIL_PKP_NFT_CONTRACT_ADDRESS=0x487A9D096BB4B7Ac1520Cb12370e31e677B175EA
# Required for Fee Contract Deployment
VINCENT_PROD_DIAMOND_ADDRESS=0xa3a602F399E9663279cdF63a290101cB6560A87e
VINCENT_DEV_DIAMOND_ADDRESS=0x57f75581e0c9e51594C8080EcC833A3592A50df8

Expand All @@ -13,4 +15,18 @@ BASE_RPC_URL=https://base.llamarpc.com
ETH_RPC_URL=https://eth.llamarpc.com
TEST_FUNDER_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
TEST_AGENT_WALLET_PKP_OWNER_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
TEST_APP_DELEGATEE_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
TEST_APP_DELEGATEE_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

# Required for Fee contract deployment
BASE_SEPOLIA_RPC_URL=
BASE_SEPOLIA_ETHERSCAN_API_KEY=

# Required for fee contract testing on base sepolia
# must have aave usdc on base sepolia. can get from https://app.aave.com/reserve-overview/?underlyingAsset=0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f&marketName=proto_base_sepolia_v3
AAVE_USDC_PRIVATE_KEY=
# must have eth on base sepolia
TEST_BASE_SEPOLIA_PRIVATE_KEY=
# must have eth on base sepolia and LITKEY on chronicle yellowstone
TEST_APP_OWNER_PRIVATE_KEY=
# must have eth on base sepolia
TEST_LIT_FOUNDATION_PRIVATE_KEY=
6 changes: 6 additions & 0 deletions packages/libs/contracts-sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ out/

# We don't commit HTML typedoc output; just json
docs/html/**/*

# Build output
dist/

# Generated Lit Actions
lit-actions/generated/
200 changes: 200 additions & 0 deletions packages/libs/contracts-sdk/TEST_RUN_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Running the Owner Attestation E2E Test

This guide explains how to run the complete E2E integration test for owner attestation signing.

## Prerequisites

1. **Environment Variables**: Create a `.env` file in the project root with:

```bash
# Private key for test wallet on Base Sepolia
# This wallet will execute deposit/withdraw transactions
TEST_BASE_SEPOLIA_PRIVATE_KEY=0x...

# Private key for app owner wallet
# Funded on Chronicle Yellowstone, will create the app and receive fees
TEST_APP_OWNER_PRIVATE_KEY=0x...

# Private key for wallet with USDC on Base Sepolia
# Used to fund the test wallet with USDC
AAVE_USDC_PRIVATE_KEY=0x...

# Vincent Diamond address on Chronicle Yellowstone (prod)
VINCENT_PROD_DIAMOND_ADDRESS=0xa3a602F399E9663279cdF63a290101cB6560A87e
```

2. **Wallet Funding**:
- `TEST_APP_OWNER_PRIVATE_KEY`: Needs ETH on Chronicle Yellowstone (for gas to register app)
- `TEST_BASE_SEPOLIA_PRIVATE_KEY`: Needs ETH on Base Sepolia (for gas)
- `AAVE_USDC_PRIVATE_KEY`: Needs ~100 USDC on Base Sepolia

## Running the Test

```bash
# From the project root
nx run contracts-sdk:test-e2e:fees

# Or with verbose output
nx run contracts-sdk:test-e2e:fees --verbose
```

## What the Test Does

The test performs a complete end-to-end flow with NO mocking:

### Step 1: App Creation (Chronicle Yellowstone)

- Generates a random app ID
- Registers the app on the Vincent Diamond contract on Chronicle Yellowstone
- Uses the real production Vincent Diamond

### Step 2: Funding (Base Sepolia)

- Transfers 100 USDC from funding wallet to test wallet
- Verifies the transfer succeeded

### Step 3: Deposit to Aave (Base Sepolia)

- Approves 50 USDC to the Fee Diamond
- Deposits the USDC to Aave through the Fee Diamond
- Verifies the deposit was recorded

### Step 4: Withdraw from Aave (Base Sepolia)

- Withdraws the deposit from Aave
- Collects any fees (may be zero for immediate withdrawal)
- Checks collected fee amount

### Step 5: Get Lit Session Signatures (Datil)

- Connects to the Datil Lit Network
- Generates session signatures for the app owner
- Authorizes PKP signing and Lit Action execution

### Step 6: Sign Owner Attestation (Datil)

- Calls the deployed Lit Action on IPFS
- Lit Action reads from Chronicle Yellowstone to verify ownership
- Lit Action signs the attestation with the PKP
- Returns signature and attestation data

### Step 7: Withdraw App Fees (Base Sepolia)

- Uses the signed attestation to withdraw collected fees
- Transfers fees from Fee Diamond to app owner wallet

### Step 8: Verification

- Checks that funds arrived in app owner wallet
- Verifies fee balance was cleared
- Asserts the amount matches expected fees

## Expected Output

```
Test wallet (Base Sepolia): 0x...
App owner wallet (Chronicle Yellowstone): 0x...
Funding wallet (Base Sepolia): 0x...
✅ Connected to Lit Network (Datil)

📝 Step 1: Creating app on Chronicle Yellowstone...
Generated App ID: 123456789
✅ App registered on Chronicle Yellowstone

💰 Step 2: Funding test wallet with USDC...
Funding wallet USDC balance: 1000.0 USDC
✅ Transferred 100.0 USDC to test wallet
Test wallet USDC balance: 100.0 USDC

📥 Step 3: Depositing USDC to Aave through Fee Diamond...
Approving 50.0 USDC...
✅ Approved USDC
Depositing to Aave...
✅ Deposited to Aave
Deposit recorded: 50.0 USDC

📤 Step 4: Withdrawing from Aave...
✅ Withdrawn from Aave
Collected app fees: 0.0 USDC
⚠️ No fees collected (expected for immediate withdrawal). Skipping fee withdrawal test.

🎉 E2E test completed successfully!
```

## Troubleshooting

### "No fees collected"

This is expected if you withdraw immediately. The test will skip the fee withdrawal part. To test with actual fees, you would need to wait for Aave interest to accrue (hours/days in real scenarios).

### "Funding wallet does not have enough USDC"

Get Base Sepolia USDC:

- Use a testnet faucet
- Bridge from Base Sepolia faucet
- Contact team for test USDC

### "Transaction failed"

- Check gas balances on both chains
- Verify contract addresses in constants are correct
- Ensure RPC endpoints are accessible

### Lit Action Errors

- Verify the IPFS CID is correct
- Check that the PKP public key matches
- Ensure Datil network is accessible

### Timeout

- The test has a 5-minute timeout
- Network congestion can cause delays
- Try again during off-peak hours

## Test Duration

Typical run time: 2-4 minutes

- Network latency: ~30 seconds
- Transaction confirmations: ~1-2 minutes
- Lit Action execution: ~30-60 seconds
- Multiple RPC calls: ~30 seconds

## Security Note

⚠️ **This test uses REAL testnets:**

- Actual transactions are broadcast
- Real Lit Action execution on Datil
- Testnet ETH and USDC are consumed
- Private keys must be kept secure

## Success Criteria

The test passes when:

- ✅ App is registered on Chronicle Yellowstone
- ✅ USDC is transferred to test wallet
- ✅ Deposit to Aave succeeds
- ✅ Withdrawal from Aave succeeds
- ✅ Lit Action signs attestation successfully
- ✅ If fees collected, withdrawal to owner succeeds
- ✅ All balances and states are verified

## Next Steps

After a successful test run:

1. Monitor the app on Chronicle Yellowstone explorer
2. Check the Fee Diamond balance on Base Sepolia
3. Verify no lingering deposits or fees
4. Document any issues or edge cases found

## Related Documentation

- [Lit Actions README](./lit-actions/README.md)
- [Fee Lit Actions README](./lit-actions/fees/README.md)
- [Fee Test README](./test/fees/README.md)
- [Fee Contracts README](./contracts/fees/README.md)
Loading