@gvnrdao/dh-lit-actions 0.0.322 → 0.0.324
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -541
- package/dist/a_dev_address-probe-signer.meta.json +1 -1
- package/dist/a_dev_address-probe.meta.json +1 -1
- package/dist/a_dev_always-signer.meta.json +1 -1
- package/dist/a_dev_authorization-dummy-b.meta.json +1 -1
- package/dist/a_dev_authorization-dummy.meta.json +1 -1
- package/dist/a_dev_ethers-version-probe.meta.json +1 -1
- package/dist/a_dev_process-payment-sign-only.meta.json +1 -1
- package/dist/agent-module-executor.action.js +1 -1
- package/dist/agent-module-executor.hash +1 -1
- package/dist/agent-module-executor.meta.json +5 -5
- package/dist/btc-address-balance.action.js +1 -1
- package/dist/btc-address-balance.hash +1 -1
- package/dist/btc-address-balance.meta.json +5 -5
- package/dist/btc-provider-probe.action.js +1 -0
- package/dist/btc-provider-probe.hash +1 -0
- package/dist/btc-provider-probe.meta.json +9 -0
- package/dist/btc-transaction-signer.action.js +1 -1
- package/dist/btc-transaction-signer.hash +1 -1
- package/dist/btc-transaction-signer.meta.json +5 -5
- package/dist/btc-utxo-invalidator.action.js +1 -1
- package/dist/btc-utxo-invalidator.hash +1 -1
- package/dist/btc-utxo-invalidator.meta.json +5 -5
- package/dist/btc-withdrawal.action.js +1 -1
- package/dist/btc-withdrawal.hash +1 -1
- package/dist/btc-withdrawal.meta.json +5 -5
- package/dist/carry-collateral-attestation.action.js +1 -0
- package/dist/carry-collateral-attestation.hash +1 -0
- package/dist/carry-collateral-attestation.meta.json +9 -0
- package/dist/carry-funding-attestation.action.js +1 -0
- package/dist/carry-funding-attestation.hash +1 -0
- package/dist/carry-funding-attestation.meta.json +9 -0
- package/dist/encrypt-parameter.meta.json +1 -1
- package/dist/extend-position-validator.action.js +1 -1
- package/dist/extend-position-validator.hash +1 -1
- package/dist/extend-position-validator.meta.json +5 -5
- package/dist/liquidation-validator.action.js +1 -1
- package/dist/liquidation-validator.hash +1 -1
- package/dist/liquidation-validator.meta.json +5 -5
- package/dist/loan-vault-btc-balance.action.js +1 -1
- package/dist/loan-vault-btc-balance.hash +1 -1
- package/dist/loan-vault-btc-balance.meta.json +5 -5
- package/dist/pkp-validator.meta.json +1 -1
- package/dist/price-oracle.meta.json +1 -1
- package/dist/process-payment-validator.action.js +1 -1
- package/dist/process-payment-validator.hash +1 -1
- package/dist/process-payment-validator.meta.json +5 -5
- package/dist/stale-spend-recovery-validator.action.js +1 -1
- package/dist/stale-spend-recovery-validator.hash +1 -1
- package/dist/stale-spend-recovery-validator.meta.json +5 -5
- package/dist/ucd-mint-validator.action.js +1 -1
- package/dist/ucd-mint-validator.hash +1 -1
- package/dist/ucd-mint-validator.meta.json +5 -5
- package/package.json +3 -2
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
- package/pkg-dist/pkg-src/index.js +235 -129
- package/pkg-dist/pkg-src/index.js.map +2 -2
- package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts +4 -0
- package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts.map +1 -1
- package/pkg-dist/src/constants/borrower-authorization-types.d.ts +1 -1
- package/pkg-dist/src/constants/chunks/bitcoin-network-config.d.ts +1 -1
- package/pkg-dist/src/constants/chunks/bitcoin-network-config.d.ts.map +1 -1
- package/pkg-dist/src/constants/chunks/carry.d.ts +55 -0
- package/pkg-dist/src/constants/chunks/carry.d.ts.map +1 -0
- package/pkg-dist/src/constants/chunks/deployment-addresses.d.ts +6 -0
- package/pkg-dist/src/constants/chunks/deployment-addresses.d.ts.map +1 -1
- package/pkg-dist/src/modules/action-bootstrap.d.ts +83 -0
- package/pkg-dist/src/modules/action-bootstrap.d.ts.map +1 -0
- package/pkg-dist/src/modules/bitcoin/pkp-signature-assert.d.ts +47 -0
- package/pkg-dist/src/modules/bitcoin/pkp-signature-assert.d.ts.map +1 -0
- package/pkg-dist/src/modules/bitcoin/recovery-evidence.d.ts +114 -0
- package/pkg-dist/src/modules/bitcoin/recovery-evidence.d.ts.map +1 -0
- package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts +38 -0
- package/pkg-dist/src/modules/bitcoin-data-provider.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/carry-attestation.module.d.ts +126 -0
- package/pkg-dist/src/modules/carry-attestation.module.d.ts.map +1 -0
- package/pkg-dist/src/modules/chain-policy.d.ts +3 -2
- package/pkg-dist/src/modules/chain-policy.d.ts.map +1 -1
- package/pkg-dist/src/modules/loan-cap.module.d.ts +39 -0
- package/pkg-dist/src/modules/loan-cap.module.d.ts.map +1 -0
- package/pkg-dist/src/modules/pinned-addresses.d.ts +1 -1
- package/pkg-dist/src/modules/pinned-addresses.d.ts.map +1 -1
- package/pkg-dist/src/modules/pro-rata-fee.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/protocol-pause.module.d.ts +27 -10
- package/pkg-dist/src/modules/protocol-pause.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/quantum-time.module.d.ts +7 -4
- package/pkg-dist/src/modules/quantum-time.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/vault-balance-consensus.module.d.ts +25 -6
- package/pkg-dist/src/modules/vault-balance-consensus.module.d.ts.map +1 -1
- package/pkg-dist/src/modules/vault-balance.module.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,541 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
A comprehensive, deterministic, and auditable build system for LIT Protocol Actions used in the Diamond Hands Protocol.
|
|
4
|
-
|
|
5
|
-
## Architecture
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
lit-actions/
|
|
9
|
-
├── src/ # LIT Action TypeScript sources
|
|
10
|
-
├── scripts/ # Build, minify, upload scripts (TypeScript)
|
|
11
|
-
├── out/ # Compiled .js files from src/
|
|
12
|
-
├── dist/ # Minified, deployment-ready .action.js files
|
|
13
|
-
├── pkg-src/ # Package source (registry + types)
|
|
14
|
-
└── pkg-dist/ # Built npm package (dh-lit-actions)
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Three-Phase System
|
|
18
|
-
|
|
19
|
-
### Phase 1: LIT Actions Development & Deployment
|
|
20
|
-
|
|
21
|
-
- **Source**: `src/*.ts` - TypeScript LIT Actions
|
|
22
|
-
- **Build**: `out/*.js` - Compiled JavaScript
|
|
23
|
-
- **Minify**: `dist/*.action.js` - Minified for IPFS deployment
|
|
24
|
-
- **Upload**: Deploy to IPFS via Pinata
|
|
25
|
-
|
|
26
|
-
### Phase 2: PKP Creation & Funding
|
|
27
|
-
|
|
28
|
-
- **Network**: Chronicle Yellowstone (175177)
|
|
29
|
-
- **Dashboard**: https://dashboard.litprotocol.com/
|
|
30
|
-
- **Purpose**: Create PKPs for LIT Action authorization
|
|
31
|
-
|
|
32
|
-
### Phase 5: CID Registration & Testing
|
|
33
|
-
|
|
34
|
-
- **Registry**: Update `pkg-src/constants/chunks/lit-actions-registry.ts`
|
|
35
|
-
- **Contracts**: Register CIDs in OperationAuthorizationRegistry
|
|
36
|
-
- **Testing**: Validate LIT Actions work with contracts
|
|
37
|
-
|
|
38
|
-
### Phase 4: NPM Package Generation
|
|
39
|
-
|
|
40
|
-
- **Package Source**: `pkg-src/` - Registry and types
|
|
41
|
-
- **Package Build**: `pkg-dist/` - Compiled npm package
|
|
42
|
-
- **Package Name**: `dh-lit-actions` - Published to npm
|
|
43
|
-
|
|
44
|
-
## Commands
|
|
45
|
-
|
|
46
|
-
### Development Commands
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm run clean # Clean out/ and dist/
|
|
50
|
-
npm run build # Build src/ → out/ (TypeScript compilation)
|
|
51
|
-
npm run minify # Minify out/ → dist/ (deployment-ready)
|
|
52
|
-
npm run upload # Upload dist/ to IPFS (mock mode by default)
|
|
53
|
-
npm run deploy # Full deployment pipeline (clean + build + minify + upload)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### NAGA TESTNET Automation Commands
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Create PKP for single LIT Action
|
|
60
|
-
npm run naga-testnet:create-pkp <cid>
|
|
61
|
-
|
|
62
|
-
# Create PKPs for all 4 LIT Actions (automated batch)
|
|
63
|
-
npm run naga-testnet:create-all-pkps
|
|
64
|
-
|
|
65
|
-
# Update registry with PKP data
|
|
66
|
-
npm run naga-testnet:update-registry
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Stage 1.5 Commands (Naga Integration Testing)
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
# Phase 1: Deploy to IPFS (Production)
|
|
73
|
-
npm run deploy # Deploy all LIT Actions to IPFS with real CIDs
|
|
74
|
-
|
|
75
|
-
# Phase 2: Fund Deployer Wallet (Manual - via LIT Bridge)
|
|
76
|
-
# Bridge 300+ LIT + 0.1+ ETH to 0x0f8f23674cc90Ef7107930a4437341fD8B460362 on Yellowstone
|
|
77
|
-
|
|
78
|
-
# Phase 3: PKP Creation (Manual - via LIT Dashboard)
|
|
79
|
-
# Go to https://dashboard.litprotocol.com/ and create 3 PKPs
|
|
80
|
-
|
|
81
|
-
# Phase 4: Registry Update
|
|
82
|
-
npm run build:package # Update registry with new CIDs
|
|
83
|
-
npm run package # Build updated package
|
|
84
|
-
|
|
85
|
-
# Phase 5: Contract Registration (Local Hardhat)
|
|
86
|
-
npx hardhat run scripts/register-naga-cids.js --network localhost
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Package Commands
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npm run clean:pkg # Clean pkg-dist/
|
|
93
|
-
npm run build:package # Update registry + build pkg-src/ → pkg-dist/
|
|
94
|
-
npm run package # Full package build (clean:pkg + build:package)
|
|
95
|
-
npm run release # Complete release (deploy + package)
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Environment Setup
|
|
99
|
-
|
|
100
|
-
1. **Copy the example configuration:**
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
cp .env.example .env
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
2. **Configure for your needs:**
|
|
107
|
-
|
|
108
|
-
### Mock Mode (Development - Default)
|
|
109
|
-
|
|
110
|
-
```env
|
|
111
|
-
MOCK_MODE=true
|
|
112
|
-
DEBUG_BUILD=false
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Production Mode (Real Pinata Upload)
|
|
116
|
-
|
|
117
|
-
```env
|
|
118
|
-
PINATA_JWT=your_pinata_jwt_token_here
|
|
119
|
-
MOCK_MODE=false
|
|
120
|
-
DEBUG_BUILD=false
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Getting Pinata JWT
|
|
124
|
-
|
|
125
|
-
1. Go to [Pinata Keys](https://app.pinata.cloud/keys)
|
|
126
|
-
2. Create a new API key
|
|
127
|
-
3. Select **Admin** permissions or at minimum:
|
|
128
|
-
- `pinFileToIPFS`
|
|
129
|
-
- `pinJSONToIPFS`
|
|
130
|
-
4. Copy the **JWT Token** (not API Key/Secret)
|
|
131
|
-
5. Add to your `.env` file as `PINATA_JWT`
|
|
132
|
-
|
|
133
|
-
## Build Commands
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
# Clean build
|
|
137
|
-
npm run clean
|
|
138
|
-
|
|
139
|
-
# Build LIT Actions (with debug)
|
|
140
|
-
DEBUG_BUILD=true npm run build
|
|
141
|
-
|
|
142
|
-
# Upload to IPFS (mock mode)
|
|
143
|
-
npm run upload
|
|
144
|
-
|
|
145
|
-
# Build + Upload
|
|
146
|
-
npm run deploy
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Mock Mode Quality
|
|
150
|
-
|
|
151
|
-
Our mock mode is **very good** for development:
|
|
152
|
-
|
|
153
|
-
- ✅ **Deterministic**: Same content = same CID
|
|
154
|
-
- ✅ **Realistic Format**: Proper IPFS CID format (`Qm...`)
|
|
155
|
-
- ✅ **Reproducible**: Perfect for testing
|
|
156
|
-
- ✅ **Hash-based**: Content integrity guaranteed
|
|
157
|
-
- ✅ **Offline Ready**: No network dependencies
|
|
158
|
-
|
|
159
|
-
**Mock CID Example**: `Qmd75a736b6ea15647bc551d8c55c6481acba3b2bcbc63`
|
|
160
|
-
|
|
161
|
-
The mock system generates CIDs based on content hash, so:
|
|
162
|
-
|
|
163
|
-
- Same TypeScript source → Same built JS → Same mock CID
|
|
164
|
-
- Perfect for development and testing
|
|
165
|
-
- Switch to real Pinata when ready for deployment
|
|
166
|
-
|
|
167
|
-
## Stage 1.5: Naga Integration Testing Guide
|
|
168
|
-
|
|
169
|
-
**Stage 1.5** enables safe testing of LIT Actions with Naga network while using stable local Hardhat contracts. This validates the LIT Actions ↔ Contracts ↔ SDK integration without breaking production Sepolia deployment.
|
|
170
|
-
|
|
171
|
-
### Prerequisites
|
|
172
|
-
|
|
173
|
-
1. **Pinata JWT**: ✅ **Already configured** in `.env`
|
|
174
|
-
```bash
|
|
175
|
-
PINATA_JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
2. **Deployer Wallet Funding**: `0x0f8f23674cc90Ef7107930a4437341fD8B460362`
|
|
179
|
-
- **Network**: Chronicle Yellowstone (175177)
|
|
180
|
-
- **Tokens Needed**:
|
|
181
|
-
- **LIT Tokens**: 300+ LIT for PKP operations (100 per PKP × 3)
|
|
182
|
-
- **ETH**: 0.1+ ETH for gas fees
|
|
183
|
-
- **Funding Source**: Bridge from Ethereum mainnet via [LIT Protocol Bridge](https://bridge.litprotocol.com/)
|
|
184
|
-
- **Verification**:
|
|
185
|
-
```bash
|
|
186
|
-
# Check balances on Yellowstone
|
|
187
|
-
cast balance 0x0f8f23674cc90Ef7107930a4437341fD8B460362 --rpc-url https://yellowstone-rpc.litprotocol.com
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
3. **Hardhat Local**: Running localhost contracts
|
|
191
|
-
4. **LIT Dashboard Access**: https://dashboard.litprotocol.com/
|
|
192
|
-
|
|
193
|
-
### Phase 1: Deploy LIT Actions to IPFS
|
|
194
|
-
|
|
195
|
-
#### Step 1: Configure Production Environment
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
# Copy and edit environment
|
|
199
|
-
cp .env.example .env
|
|
200
|
-
|
|
201
|
-
# Edit .env for production deployment
|
|
202
|
-
PINATA_JWT=your_pinata_jwt_token_here
|
|
203
|
-
MOCK_MODE=false
|
|
204
|
-
DEBUG_BUILD=false
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
#### Step 2: Get Pinata JWT
|
|
208
|
-
|
|
209
|
-
1. Visit [Pinata Keys](https://app.pinata.cloud/keys)
|
|
210
|
-
2. Create new API key with **Admin** permissions:
|
|
211
|
-
- `pinFileToIPFS`
|
|
212
|
-
- `pinJSONToIPFS`
|
|
213
|
-
3. Copy the **JWT Token** (not API Key/Secret)
|
|
214
|
-
4. Add to `.env` as `PINATA_JWT`
|
|
215
|
-
|
|
216
|
-
#### ✅ COMPLETED: LIT Actions Deployed to IPFS
|
|
217
|
-
|
|
218
|
-
**Deployed CIDs:**
|
|
219
|
-
- ✅ `ucd-mint-validator.action.js` → `QmSggwuiQJpsn5F1qjcD9Bpe5WaRB2MgY2PiFVzpaNFvN8`
|
|
220
|
-
- ✅ `btc-withdrawal.action.js` → `QmYs2UWxfmjX3MxaSq2VoZ5A2pS2LN3JTSgaoHYSYaopy7`
|
|
221
|
-
- ✅ `process-payment-validator.action.js` → `QmPK9ViEH75JPcDcdDhUgEk9vGPvBDNSwPnQALbdSqVAjV`
|
|
222
|
-
- ✅ `extend-position-validator.action.js` → `QmYwKsf2yNSyLUeVw3KvVasPZqGCA6LPgHetFqMwqh5YKP`
|
|
223
|
-
|
|
224
|
-
**Registry Updated**: `DH_LIT_ACTIONS_NAGA_TEST` now contains real deployed CIDs.
|
|
225
|
-
|
|
226
|
-
### Phase 2: Fund Deployer Wallet
|
|
227
|
-
|
|
228
|
-
#### ✅ COMPLETED: Wallet Funding
|
|
229
|
-
- **Deployer Wallet**: `0x0f8f23674cc90Ef7107930a4437341fD8B460362`
|
|
230
|
-
- **Network**: Chronicle Yellowstone (175177) - NAGA TESTNET
|
|
231
|
-
- **Status**: ✅ **FUNDED** with ETH and LIT tokens
|
|
232
|
-
- **Verification**:
|
|
233
|
-
```bash
|
|
234
|
-
cast balance 0x0f8f23674cc90Ef7107930a4437341fD8B460362 --rpc-url https://yellowstone-rpc.litprotocol.com
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Phase 4: Create Naga Testnet PKPs
|
|
238
|
-
|
|
239
|
-
#### Step 1: Access LIT Dashboard
|
|
240
|
-
|
|
241
|
-
1. Visit https://dashboard.litprotocol.com/
|
|
242
|
-
2. Connect wallet `0x0f8f23674cc90Ef7107930a4437341fD8B460362`
|
|
243
|
-
3. Switch to **Chronicle Yellowstone** network (175177)
|
|
244
|
-
|
|
245
|
-
#### Step 2: Create PKPs for Each LIT Action
|
|
246
|
-
|
|
247
|
-
**Create 4 PKPs (one for each deployed LIT Action):**
|
|
248
|
-
|
|
249
|
-
1. **UCD Mint Validator PKP**: `QmSggwuiQJpsn5F1qjcD9Bpe5WaRB2MgY2PiFVzpaNFvN8`
|
|
250
|
-
2. **BTC Withdrawal PKP**: `QmYs2UWxfmjX3MxaSq2VoZ5A2pS2LN3JTSgaoHYSYaopy7`
|
|
251
|
-
3. **Process Payment PKP**: `QmPK9ViEH75JPcDcdDhUgEk9vGPvBDNSwPnQALbdSqVAjV`
|
|
252
|
-
4. **Extend Position PKP**: `QmYwKsf2yNSyLUeVw3KvVasPZqGCA6LPgHetFqMwqh5YKP`
|
|
253
|
-
|
|
254
|
-
**For each PKP:**
|
|
255
|
-
1. Click "Create PKP"
|
|
256
|
-
2. Choose authentication method (wallet address recommended)
|
|
257
|
-
3. **Add Authorized IPFS CID**: Paste the corresponding CID above
|
|
258
|
-
4. Wait for PKP creation and authorization
|
|
259
|
-
5. **Fund with 100+ LIT tokens** each
|
|
260
|
-
6. Verify ownership and authorization in dashboard
|
|
261
|
-
|
|
262
|
-
#### Step 3: Record PKP Details
|
|
263
|
-
|
|
264
|
-
**For each PKP, record:**
|
|
265
|
-
- Token ID
|
|
266
|
-
- ETH Address
|
|
267
|
-
- Public Key
|
|
268
|
-
- Authorized CID (should match above)
|
|
269
|
-
|
|
270
|
-
**Example PKP Structure:**
|
|
271
|
-
```json
|
|
272
|
-
{
|
|
273
|
-
"tokenId": "123456789...",
|
|
274
|
-
"ethAddress": "0x1234...",
|
|
275
|
-
"publicKey": "0x04abcd...",
|
|
276
|
-
"authorizedCid": "QmSggwuiQJpsn5F1qjcD9Bpe5WaRB2MgY2PiFVzpaNFvN8"
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Phase 3: Update Registry & Register CIDs
|
|
281
|
-
|
|
282
|
-
#### ✅ COMPLETED: Registry Updated
|
|
283
|
-
|
|
284
|
-
**File**: `pkg-src/constants/chunks/lit-actions-registry.ts`
|
|
285
|
-
|
|
286
|
-
- ✅ `DH_LIT_ACTIONS_NAGA_TEST` updated with real deployed CIDs
|
|
287
|
-
- ✅ All 4 LIT Actions have `deployed: true` status
|
|
288
|
-
- ✅ File sizes and deployment timestamps updated
|
|
289
|
-
- ✅ Package rebuilt and published
|
|
290
|
-
|
|
291
|
-
#### SDK Network Support
|
|
292
|
-
|
|
293
|
-
**File**: `../sdk/src/constants/chunks/environment.ts`
|
|
294
|
-
|
|
295
|
-
- ✅ Added `"naga-test"` to `validNetworks` array
|
|
296
|
-
- ✅ SDK can now validate `litNetwork: "naga-test"`
|
|
297
|
-
|
|
298
|
-
#### Local Contract Registration
|
|
299
|
-
|
|
300
|
-
**Next Step**: Register CIDs in local Hardhat contracts after PKPs are created.
|
|
301
|
-
|
|
302
|
-
**Registration Script**: `../contracts/scripts/register-naga-test-cids.js`
|
|
303
|
-
|
|
304
|
-
```javascript
|
|
305
|
-
const { ethers } = require('hardhat');
|
|
306
|
-
const { DH_LIT_ACTIONS_NAGA_TEST } = require('../../lit-actions/pkg-dist/constants/chunks/lit-actions-registry');
|
|
307
|
-
|
|
308
|
-
async function main() {
|
|
309
|
-
const registry = await ethers.getContractAt(
|
|
310
|
-
'OperationAuthorizationRegistry',
|
|
311
|
-
process.env.OPERATION_AUTHORIZATION_REGISTRY_ADDRESS
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
// Register each Naga Testnet LIT Action CID with its PKP
|
|
315
|
-
for (const [actionName, actionData] of Object.entries(DH_LIT_ACTIONS_NAGA_TEST)) {
|
|
316
|
-
const version = actionName.includes('ucdMint') ? 4 :
|
|
317
|
-
actionName.includes('btcWithdrawal') ? 2 :
|
|
318
|
-
actionName.includes('processPayment') ? 1 :
|
|
319
|
-
actionName.includes('extendPosition') ? 4 : 1;
|
|
320
|
-
|
|
321
|
-
await registry.addValidator(version, actionData.pkp.ethAddress, actionData.cid);
|
|
322
|
-
console.log(`✅ Registered ${actionName} v${version}: ${actionData.cid}`);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
main().catch(console.error);
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
**Run after PKP creation**:
|
|
330
|
-
```bash
|
|
331
|
-
cd contracts
|
|
332
|
-
npx hardhat run scripts/register-naga-test-cids.js --network localhost
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Phase 5: Test NAGA TESTNET Integration
|
|
336
|
-
|
|
337
|
-
#### Step 1: Update Registry with PKP Details
|
|
338
|
-
|
|
339
|
-
After creating PKPs on the dashboard, update the registry with PKP information:
|
|
340
|
-
|
|
341
|
-
**File**: `pkg-src/constants/chunks/lit-actions-registry.ts`
|
|
342
|
-
|
|
343
|
-
For each LIT Action in `DH_LIT_ACTIONS_NAGA_TEST`, update the `pkp` object:
|
|
344
|
-
```typescript
|
|
345
|
-
pkp: {
|
|
346
|
-
tokenId: "YOUR_PKP_TOKEN_ID", // From dashboard
|
|
347
|
-
ethAddress: "0xYOUR_PKP_ADDRESS", // From dashboard
|
|
348
|
-
publicKey: "0x04YOUR_PKP_PUBLIC_KEY", // From dashboard
|
|
349
|
-
mintTxHash: "naga-test-mint", // Transaction hash
|
|
350
|
-
authTxHash: "confirmed", // Authorization status
|
|
351
|
-
burnTxHash: "pending", // Will be set when burned
|
|
352
|
-
immutable: false, // Test PKPs are mutable
|
|
353
|
-
authorizedCidHex: cidToHex("CID_HERE"), // Auto-calculated
|
|
354
|
-
createdAt: Date.now(),
|
|
355
|
-
}
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
#### Step 2: Register CIDs in Local Contracts
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
cd ../contracts
|
|
362
|
-
npx hardhat run scripts/register-naga-test-cids.js --network localhost
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
#### Step 3: Create SDK Test Configuration
|
|
366
|
-
|
|
367
|
-
**File**: `../sdk/tests/naga-test-config.ts`
|
|
368
|
-
|
|
369
|
-
```typescript
|
|
370
|
-
export const nagaTestConfig = {
|
|
371
|
-
mode: 'standalone' as const,
|
|
372
|
-
ethRpcUrl: 'http://127.0.0.1:8545', // Local Hardhat
|
|
373
|
-
litNetwork: 'naga-test' as const, // NAGA TESTNET
|
|
374
|
-
contractAddresses: {
|
|
375
|
-
// Local Hardhat addresses (from Stage 1)
|
|
376
|
-
positionManager: '0x...',
|
|
377
|
-
// ... other local addresses
|
|
378
|
-
},
|
|
379
|
-
bitcoinProviders: [{
|
|
380
|
-
url: 'http://127.0.0.1:18443',
|
|
381
|
-
network: 'regtest' as const,
|
|
382
|
-
}],
|
|
383
|
-
// Test PKP signers will be loaded from registry
|
|
384
|
-
};
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
#### Step 4: Run NAGA TESTNET Integration Tests
|
|
388
|
-
|
|
389
|
-
```bash
|
|
390
|
-
cd ../sdk
|
|
391
|
-
npm test -- --testPathPattern="naga-test-integration.test.ts"
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
**Expected Results:**
|
|
395
|
-
- ✅ LIT Actions execute on NAGA TESTNET
|
|
396
|
-
- ✅ PKPs authorize operations successfully
|
|
397
|
-
- ✅ Local contracts accept NAGA TESTNET LIT Actions
|
|
398
|
-
- ✅ SDK operations work end-to-end with hybrid setup
|
|
399
|
-
|
|
400
|
-
### Troubleshooting
|
|
401
|
-
|
|
402
|
-
#### IPFS Deployment Issues
|
|
403
|
-
- **403 Forbidden**: Check Pinata JWT permissions
|
|
404
|
-
- **CID Mismatch**: Ensure `MOCK_MODE=false`
|
|
405
|
-
- **Upload Timeout**: Check network connectivity
|
|
406
|
-
|
|
407
|
-
#### PKP Issues
|
|
408
|
-
- **Insufficient Funds**: Send more LIT tokens to PKP
|
|
409
|
-
- **Wrong Network**: Ensure using Chronicle Yellowstone (175177)
|
|
410
|
-
- **Auth Failed**: Verify authentication method setup
|
|
411
|
-
|
|
412
|
-
#### Contract Registration Issues
|
|
413
|
-
- **CID Not Recognized**: Verify CID format and registration
|
|
414
|
-
- **PKP Not Authorized**: Check PKP address and token balance
|
|
415
|
-
- **Version Mismatch**: Ensure correct validator versions
|
|
416
|
-
|
|
417
|
-
### Current Status
|
|
418
|
-
|
|
419
|
-
**✅ COMPLETED:**
|
|
420
|
-
- ✅ LIT Actions deployed to IPFS with permanent CIDs
|
|
421
|
-
- ✅ Registry updated with real deployed CIDs
|
|
422
|
-
- ✅ Deployer wallet funded and ready
|
|
423
|
-
- ✅ Package rebuilt with NAGA TESTNET support
|
|
424
|
-
|
|
425
|
-
**🔄 NEXT STEPS:**
|
|
426
|
-
1. **Create PKPs** on https://dashboard.litprotocol.com/ (Chronicle Yellowstone)
|
|
427
|
-
2. **Authorize each PKP** with corresponding LIT Action CID
|
|
428
|
-
3. **Fund PKPs** with 100+ LIT tokens each
|
|
429
|
-
4. **Update registry** with PKP details
|
|
430
|
-
5. **Register CIDs** in local Hardhat contracts
|
|
431
|
-
6. **Run integration tests** with NAGA TESTNET + Hardhat hybrid
|
|
432
|
-
|
|
433
|
-
### Next Steps After Completion
|
|
434
|
-
|
|
435
|
-
**After NAGA TESTNET Success:**
|
|
436
|
-
1. **Proceed to Stage 2**: Full production deployment
|
|
437
|
-
2. **Deploy Contracts**: Move from Hardhat to Sepolia/Ethereum
|
|
438
|
-
3. **Full Integration**: Complete end-to-end testing
|
|
439
|
-
|
|
440
|
-
**NAGA TESTNET Complete When:**
|
|
441
|
-
- ✅ 4 PKPs created and funded on Chronicle Yellowstone
|
|
442
|
-
- ✅ Each PKP authorized with correct LIT Action CID
|
|
443
|
-
- ✅ Registry updated with complete PKP details
|
|
444
|
-
- ✅ Local contracts accept NAGA TESTNET LIT Action CIDs
|
|
445
|
-
- ✅ SDK integration tests pass with hybrid setup
|
|
446
|
-
|
|
447
|
-
## Automated NAGA TESTNET PKP Creation
|
|
448
|
-
|
|
449
|
-
**✅ NOW AVAILABLE**: Full automation for NAGA TESTNET PKP creation using V8 SDK!
|
|
450
|
-
|
|
451
|
-
### Why Automated Now?
|
|
452
|
-
|
|
453
|
-
- **✅ SDK Dependencies**: Added `@lit-protocol/auth` and `@lit-protocol/networks`
|
|
454
|
-
- **✅ Network Support**: V8 SDK supports `naga-test` network configuration
|
|
455
|
-
- **✅ Contract Addresses**: Found Chronicle Yellowstone PKP contract addresses
|
|
456
|
-
- **✅ Scripts Created**: Automated scripts for individual and batch PKP creation
|
|
457
|
-
|
|
458
|
-
### Automated Process Overview
|
|
459
|
-
|
|
460
|
-
```
|
|
461
|
-
1. Deploy LIT Actions to IPFS ✅ (Already Done)
|
|
462
|
-
2. Create PKPs Automatically 🤖 (New!)
|
|
463
|
-
3. Update Registry Automatically 🤖 (New!)
|
|
464
|
-
4. Register CIDs in Contracts ✅ (Existing)
|
|
465
|
-
5. Run Integration Tests ✅ (Existing)
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
### Quick Start - Automated NAGA TESTNET
|
|
469
|
-
|
|
470
|
-
```bash
|
|
471
|
-
# 1. Ensure wallet is funded (Chronicle Yellowstone)
|
|
472
|
-
# Visit: https://chronicle-yellowstone-faucet.getlit.dev/
|
|
473
|
-
|
|
474
|
-
# 2. Create all PKPs automatically
|
|
475
|
-
npm run naga-testnet:create-all-pkps
|
|
476
|
-
|
|
477
|
-
# 3. Update registry with PKP data
|
|
478
|
-
npm run naga-testnet:update-registry
|
|
479
|
-
|
|
480
|
-
# 4. Rebuild package
|
|
481
|
-
npm run package
|
|
482
|
-
|
|
483
|
-
# 5. Register CIDs in local contracts (cd ../contracts)
|
|
484
|
-
# npx hardhat run scripts/register-naga-test-cids.js --network localhost
|
|
485
|
-
|
|
486
|
-
# 6. Run integration tests
|
|
487
|
-
# npm test -- --testPathPattern="naga-test-integration.test.ts"
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
### Manual Alternative Still Available
|
|
491
|
-
|
|
492
|
-
If automation fails, you can still create PKPs manually via the dashboard:
|
|
493
|
-
|
|
494
|
-
1. Visit https://dashboard.litprotocol.com/
|
|
495
|
-
2. Switch to Chronicle Yellowstone (175177)
|
|
496
|
-
3. Create PKPs and authorize CIDs manually
|
|
497
|
-
4. Use `npm run naga-testnet:update-registry` to update with your PKP data
|
|
498
|
-
|
|
499
|
-
### What the Automation Does
|
|
500
|
-
|
|
501
|
-
**Batch PKP Creation** (`create-all-naga-testnet-pkps.ts`):
|
|
502
|
-
- ✅ Uses V8 SDK with `naga-test` network
|
|
503
|
-
- ✅ Creates PKP for each of 4 LIT Actions
|
|
504
|
-
- ✅ Authorizes correct CID for each PKP
|
|
505
|
-
- ✅ Keeps PKPs mutable (testnet-friendly)
|
|
506
|
-
- ✅ Saves results to JSON file
|
|
507
|
-
|
|
508
|
-
**Registry Update** (`update-naga-testnet-registry.ts`):
|
|
509
|
-
- ✅ Reads PKP creation results
|
|
510
|
-
- ✅ Updates `DH_LIT_ACTIONS_NAGA_TEST` with real PKP data
|
|
511
|
-
- ✅ Sets `deployed: true` and timestamps
|
|
512
|
-
- ✅ Rebuilds package automatically
|
|
513
|
-
|
|
514
|
-
### Troubleshooting Automation
|
|
515
|
-
|
|
516
|
-
**Common Issues:**
|
|
517
|
-
- **"Insufficient funds"**: Get more tstLPX from faucet
|
|
518
|
-
- **"Network timeout"**: Wait and retry (testnet can be slow)
|
|
519
|
-
- **"Authorization failed"**: Check CID format and network selection
|
|
520
|
-
|
|
521
|
-
**Debug Commands:**
|
|
522
|
-
```bash
|
|
523
|
-
# Check single PKP creation
|
|
524
|
-
npm run naga-testnet:create-pkp QmSggwuiQJpsn5F1qjcD9Bpe5WaRB2MgY2PiFVzpaNFvN8
|
|
525
|
-
|
|
526
|
-
# View PKP results
|
|
527
|
-
cat naga-testnet-pkp-results.json
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### Evolution from Manual to Automated
|
|
531
|
-
|
|
532
|
-
**Before**: Manual dashboard creation required for NAGA TESTNET
|
|
533
|
-
- **Reason**: SDK compatibility issues, missing dependencies, network differences
|
|
534
|
-
|
|
535
|
-
**Now**: Full automation available for NAGA TESTNET
|
|
536
|
-
- **Reason**: Updated dependencies, V8 SDK support for `naga-test`, proper contract addresses
|
|
537
|
-
|
|
538
|
-
**Production (DATIL/NAGA)**: Automated scripts in single pipeline
|
|
539
|
-
**Testing (NAGA TESTNET)**: **Now fully automated** with proper error handling and batch processing
|
|
540
|
-
|
|
541
|
-
**This provides the critical validation bridge between development and production deployment.**
|
|
1
|
+
Internal Diamond Hands Lit Actions registry and bundled action code. Do not install this package directly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _LIT_ACTION_=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})(i,{main:()=>main});var o=1,a=["function agentOf(address user) view returns (tuple(address agent, uint64 validUntil, uint8 status, uint64 registeredAt, uint64 revokedAt))","function canMint(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)","function canRepay(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canRenew(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canWithdraw(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)"],s=["NONE","PAUSED","NO_GRANT","SCOPE_DISABLED","NO_AGENT","AGENT_REVOKED","AGENT_EXPIRED","NOT_BORROWER","POSITION_TERMINAL"],d=e=>{const t=Number(e);return Number.isInteger(t)&&t>=0&&t<s.length?s[t]:`UNKNOWN(${String(e)})`};var u={1:{PositionManager:"0x12A1836e56139ccaD8722B89519d84233efc224B",LoanOperationsManagerModule:"0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",BTCSpendAuthorizer:"0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",BitcoinProviderRegistry:"0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",LITActionValidator:"0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",PositionDelegateRegistry:"0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"},11155111:{PositionManager:"0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",LoanOperationsManagerModule:"0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",BTCSpendAuthorizer:"0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",BitcoinProviderRegistry:"0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",LITActionValidator:"0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",PositionDelegateRegistry:"0x482369De283622E7b05731875ec137d4E3D208F9"}};var c={1:{AgentDelegationRegistry:"0x54853b7E91ce2Be34ce65655D80c4447e67187Fa",BitcoinWithdrawalAddressRegistry:"0xf667f77FDba7458345f227eB6Bfe4148243E7270"},11155111:{AgentModuleFactory:"0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5",AgentDelegationRegistry:"0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",BitcoinWithdrawalAddressRegistry:"0x6376D392097F0A81e51BD83960A97EA20eaf1dbe"}};var p="DiamondHands.Protocol",m="1",g={MintRequest:[{name:"positionId",type:"bytes32"},{name:"mintAmount",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],RepayRequest:[{name:"positionId",type:"bytes32"},{name:"paymentAmount",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],RenewRequest:[{name:"positionId",type:"bytes32"},{name:"selectedTerm",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],WithdrawRequest:[{name:"positionId",type:"bytes32"},{name:"totalDeduction",type:"uint256"},{name:"withdrawalAddress",type:"string"},{name:"quantumTimestamp",type:"uint256"}]};function l(e){const t=g[e];if(!t)throw new Error(`Unknown borrower authorization primary type "${e}"; expected one of ${Object.keys(g).join(", ")}`);return{[e]:t.map((e=>({...e})))}}function f(e,t){if(!Number.isInteger(e)||e<=0)throw new Error(`Borrower authorization domain requires a positive integer chainId, got ${String(e)}`);const n=function(e){return u[e]??null}(e),r=n?.LoanOperationsManagerModule;if(r&&t&&r.toLowerCase()!==t.toLowerCase())throw new Error(`Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${e}: caller ${t}, pinned ${r}`);const i=r??t;if(!i)throw new Error(`No pinned LoanOperationsManagerModule for chainId ${e} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`);return{name:p,version:m,chainId:e,verifyingContract:i}}var h=(e=>(e.SEPOLIA="sepolia",e.ETHEREUM="ethereum",e.HARDHAT="hardhat",e))(h||{}),w={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},y={ethereum:1,sepolia:11155111,hardhat:1337};var b={hardhat:{chain:"hardhat",chainId:y.hardhat,bitcoinNetwork:w.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:y.sepolia,bitcoinNetwork:w.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},ethereum:{chain:"ethereum",chainId:y.ethereum,bitcoinNetwork:w.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function A(e){const t=function(e){const t=e.toLowerCase().trim();if("sepolia"===t)return"sepolia";if("ethereum"===t||"mainnet"===t)return"ethereum";if("hardhat"===t)return"hardhat";throw new Error(`Unsupported EVM chain: "${e}". Supported chains: ${Object.values(h).join(", ")}`)}(e),n=b[t];if(!n)throw new Error(`No chain policy registered for "${e}"`);return n}var I=["AgentModuleFactory","AgentDelegationRegistry","BitcoinWithdrawalAddressRegistry"];function v(e,t){if(!e.pinContractAddresses){const e={};for(const n of I){const r=t?.[n];"string"==typeof r&&r.length>0&&(e[n]=r)}return e}const n=(r=e.chainId,c[r]??{});var r;const i={};for(const r of I){const o=n[r];if(!o)continue;const a=t?.[r];if("string"==typeof a&&a.length>0&&a.toLowerCase()!==o.toLowerCase())throw new Error(`Caller-supplied "${r}" (${a}) contradicts the pinned ${e.chain} address (${o}); refusing to evaluate the Safe-agent authorization arm`);i[r]=o}return i}var E=["function execute(address target, bytes calldata data)"],x=["function safe() view returns (address)","function agent() view returns (address)","function isWhitelisted(address target, bytes4 selector) view returns (bool)"],C=["function isFromFactory(address) view returns (bool)"],D={mint:[{signature:"mintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes)",positionIdPath:"flat"}],repay:[{signature:"approve(address,uint256)",positionIdPath:null},{signature:"makePayment(bytes32,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],renew:[{signature:"extendPosition(bytes32,uint256,uint256,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],withdraw:[{signature:"withdrawBTC((bytes32,bytes32,bytes32,bytes32,bytes32,string,uint256,uint256,uint256,uint256,string,uint32),bytes,bytes)",positionIdPath:"tuple"}]};var P,F=(e,t)=>"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase();function $(e,t){if("string"!=typeof e||!/^0x[0-9a-fA-F]{40}$/.test(e))throw new Error(`[agent-module-executor] ${t} must be a 0x address, got ${JSON.stringify(e)}`);return e}async function main(e){const t=e?.mode;if("authorize"!==t&&"execute"!==t)throw new Error(`[agent-module-executor] mode must be "authorize" or "execute", got ${JSON.stringify(t)}`);const n=$(e?.safe,"safe"),r=$(e?.module,"module"),i=$(e?.pkpId,"pkpId");if("string"!=typeof e?.positionId||!/^0x[0-9a-fA-F]{64}$/.test(e.positionId))throw new Error("[agent-module-executor] positionId must be a bytes32 hex string");if("string"!=typeof e?.chain||0===e.chain.length)throw new Error('[agent-module-executor] chain is required (e.g. "sepolia")');const s=A(e.chain);if("number"!=typeof e?.chainId||!Number.isInteger(e.chainId))throw new Error("[agent-module-executor] chainId must be an integer");if(e.chainId!==s.chainId)throw new Error(`[agent-module-executor] chainId ${e.chainId} does not match the policy chainId ${s.chainId} derived from chain=${e.chain} \u2014 refusing`);if("string"!=typeof e?.rpcUrl||!e.rpcUrl.startsWith("http"))throw new Error("[agent-module-executor] rpcUrl is required (server-supplied)");const u=v(s,e?.contractAddresses),c=$(u.AgentDelegationRegistry,"AgentDelegationRegistry (pinned; unavailable on this chain)"),p=$(u.AgentModuleFactory,"AgentModuleFactory (pinned; unavailable on this chain)"),m=new ethers.providers.JsonRpcProvider(e.rpcUrl),g=new ethers.Contract(p,C,m);if(!0!==await g.isFromFactory(r))throw new Error(`[agent-module-executor] module ${r} was not deployed by the canonical AgentModuleFactory ${p} \u2014 refusing to act through an unprovenanced module`);const h=new ethers.Contract(r,x,m),[w,y]=await Promise.all([h.safe(),h.agent()]);if(!F(w,n))throw new Error(`[agent-module-executor] module ${r} is bound to Safe ${w}, not ${n}`);const b=await async function(e){const{provider:t,registryAddress:n,safe:r,positionId:i,op:s,candidateAgent:u}=e,c=new ethers.Contract(n,a,t),p=await c.agentOf(r),m=p.agent??p[0],g=Number(p.status??p[2]),l=Number(p.validUntil??p[1]);if(g!==o)throw new Error(`[agent-authorization] Safe ${r} has no Active agent registration (status=${g}) \u2014 refusing`);if(m.toLowerCase()!==u.toLowerCase())throw new Error(`[agent-authorization] Safe ${r}'s registered agent is ${m}, but ${u} was supplied \u2014 refusing to sign with a key that is merely group-co-member`);if(!Number.isFinite(l)||0===l)throw new Error(`[agent-authorization] agent record for ${r} has no validUntil`);const f="mint"===s?"canMint":"repay"===s?"canRepay":"renew"===s?"canRenew":"withdraw"===s?"canWithdraw":null;if(!f)throw new Error(`[agent-authorization] unknown op ${String(s)}`);const h=await c[f](i,m),w=h.ok??h[0],y=h.reason??h[1];if(!0!==w)throw new Error(`[agent-authorization] registry refused ${s} for position ${i} (agent ${m}): ${d(y)}`);const b=h.effectiveFloorBps??h[2];return{agent:m,validUntil:l,effectiveFloorBps:void 0!==b?Number(b):void 0}}({provider:m,registryAddress:c,safe:n,positionId:e.positionId,op:e.op,candidateAgent:i});if(!F(y,i))throw new Error(`[agent-module-executor] module agent is ${y} but pkpId ${i} was supplied \u2014 refusing to sign with a key the module does not recognise`);const I=await Lit.Actions.getPrivateKey({pkpId:i}),P="string"==typeof I?I.startsWith("0x")?I:`0x${I}`:String(I),B=new ethers.Wallet(P);if(!F(B.address,i))throw new Error(`[agent-module-executor] getPrivateKey returned a key for ${B.address}, not ${i}`);const R={success:!0,mode:t,module:r,agent:b.agent,op:e.op};if("authorize"===t){if("number"!=typeof e.timestamp||!Number.isInteger(e.timestamp))throw new Error("[agent-module-executor] timestamp is required for mode=authorize (quantum-aligned)");const{domain:t,types:n,message:r}=function(e){const t=f(e.chainId,e.contractAddresses?.LoanOperationsManagerModule);if("renew"===e.op){if("number"!=typeof e.selectedTerm)throw new Error("[agent-module-executor] selectedTerm is required for op=renew");return{domain:t,types:l("RenewRequest"),message:{positionId:e.positionId,selectedTerm:e.selectedTerm,quantumTimestamp:e.timestamp}}}if("string"!=typeof e.amount||0===e.amount.length)throw new Error(`[agent-module-executor] amount is required for op=${e.op}`);if("withdraw"===e.op){if("string"!=typeof e.destinationAddress||0===e.destinationAddress.length)throw new Error("[agent-module-executor] destinationAddress is required for op=withdraw");return{domain:t,types:l("WithdrawRequest"),message:{positionId:e.positionId,totalDeduction:e.amount,withdrawalAddress:e.destinationAddress,quantumTimestamp:e.timestamp}}}const n="mint"===e.op?"MintRequest":"RepayRequest";return{domain:t,types:l(n),message:{positionId:e.positionId,["mint"===e.op?"mintAmount":"paymentAmount"]:e.amount,quantumTimestamp:e.timestamp}}}(e),i=await B._signTypedData(t,n,r);return{...R,authorization:{timestamp:e.timestamp,signature:i,signer:B.address}}}const N=$(e?.target,"target");if("string"!=typeof e?.innerData||!/^0x[0-9a-fA-F]{8,}$/.test(e.innerData))throw new Error("[agent-module-executor] innerData must be 0x-hex with a 4-byte selector for mode=execute");const T=e?.tx;if(!T||"number"!=typeof T.nonce||!Number.isInteger(T.nonce)||"string"!=typeof T.gasLimit||"string"!=typeof T.maxFeePerGas||"string"!=typeof T.maxPriorityFeePerGas)throw new Error("[agent-module-executor] tx.{nonce,gasLimit,maxFeePerGas,maxPriorityFeePerGas} are required for mode=execute and must be caller-supplied (multi-node determinism)");const O=e.innerData.slice(0,10);if(!0!==await h.isWhitelisted(N,O))throw new Error(`[agent-module-executor] (${N}, ${O}) is not on module ${r}'s whitelist \u2014 refusing`);const L=(D[e.op]??[]).find((e=>{return(t=e.signature,ethers.utils.id(t).slice(0,10)).toLowerCase()===O.toLowerCase();var t}));if(!L)throw new Error(`[agent-module-executor] op=${e.op} does not authorize selector ${O}. createPosition, setPositionDelegate, and approve-outside-a-repay-grant have no corresponding AgentDelegationRegistry scope and are never reachable through this action (setPositionDelegate specifically: vigil concern C-43) \u2014 refusing to sign`);if(null!==L.positionIdPath){const t=L.signature.slice(0,L.signature.indexOf("(")),n=new ethers.utils.Interface([`function ${L.signature}`]).decodeFunctionData(t,e.innerData),r="tuple"===L.positionIdPath?n[0][0]:n[0];if(!F(r,e.positionId))throw new Error(`[agent-module-executor] innerData targets position ${r}, but the scope grant checked in step 3 was for ${e.positionId} \u2014 refusing to sign a call against a different position than the one authorized`)}const _=new ethers.utils.Interface(E).encodeFunctionData("execute",[N,e.innerData]),M=await B.signTransaction({to:r,data:_,value:0,chainId:e.chainId,nonce:T.nonce,gasLimit:ethers.BigNumber.from(T.gasLimit),maxFeePerGas:ethers.BigNumber.from(T.maxFeePerGas),maxPriorityFeePerGas:ethers.BigNumber.from(T.maxPriorityFeePerGas),type:2});return{...R,signedTransaction:M}}return P=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let d of n(o))r.call(i,d)||d===a||e(i,d,{get:()=>o[d],enumerable:!(s=t(o,d))||s.enumerable});return i})(e({},"__esModule",{value:!0}),P)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
|
|
1
|
+
var _LIT_ACTION_=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})(i,{main:()=>main});var o=1,a=["function agentOf(address user) view returns (tuple(address agent, uint64 validUntil, uint8 status, uint64 registeredAt, uint64 revokedAt))","function canMint(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)","function canRepay(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canRenew(bytes32 positionId, address agent) view returns (bool ok, uint8 reason)","function canWithdraw(bytes32 positionId, address agent) view returns (bool ok, uint8 reason, uint32 effectiveFloorBps)"],s=["NONE","PAUSED","NO_GRANT","SCOPE_DISABLED","NO_AGENT","AGENT_REVOKED","AGENT_EXPIRED","NOT_BORROWER","POSITION_TERMINAL"],d=e=>{const t=Number(e);return Number.isInteger(t)&&t>=0&&t<s.length?s[t]:`UNKNOWN(${String(e)})`};var u={1:{PositionManager:"0x12A1836e56139ccaD8722B89519d84233efc224B",LoanOperationsManagerModule:"0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",BTCSpendAuthorizer:"0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",BitcoinProviderRegistry:"0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",LITActionValidator:"0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",PositionDelegateRegistry:"0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",TermManagerModule:"0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",UCDController:"0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",LiquidationManagerModule:"0x74B28695352E7bf736D6c9F76ccb7B4439477De9"},11155111:{PositionManager:"0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",LoanOperationsManagerModule:"0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",BTCSpendAuthorizer:"0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",BitcoinProviderRegistry:"0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",LITActionValidator:"0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",PositionDelegateRegistry:"0x482369De283622E7b05731875ec137d4E3D208F9",TermManagerModule:"0x94Adc6F9558368B1482197584f1fc7133Ecf835b",UCDController:"0x360Bde4e489ee94E26601B206932De09EE60FF04",LiquidationManagerModule:"0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"}};var c={1:{AgentDelegationRegistry:"0x54853b7E91ce2Be34ce65655D80c4447e67187Fa",BitcoinWithdrawalAddressRegistry:"0xf667f77FDba7458345f227eB6Bfe4148243E7270"},11155111:{AgentModuleFactory:"0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5",AgentDelegationRegistry:"0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",BitcoinWithdrawalAddressRegistry:"0x6376D392097F0A81e51BD83960A97EA20eaf1dbe"}};var p="DiamondHands.Protocol",m="1",l={MintRequest:[{name:"positionId",type:"bytes32"},{name:"mintAmount",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],RepayRequest:[{name:"positionId",type:"bytes32"},{name:"paymentAmount",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],RenewRequest:[{name:"positionId",type:"bytes32"},{name:"selectedTerm",type:"uint256"},{name:"quantumTimestamp",type:"uint256"}],WithdrawRequest:[{name:"positionId",type:"bytes32"},{name:"totalDeduction",type:"uint256"},{name:"withdrawalAddress",type:"string"},{name:"quantumTimestamp",type:"uint256"}]};function g(e){const t=l[e];if(!t)throw new Error(`Unknown borrower authorization primary type "${e}"; expected one of ${Object.keys(l).join(", ")}`);return{[e]:t.map((e=>({...e})))}}function f(e,t){if(!Number.isInteger(e)||e<=0)throw new Error(`Borrower authorization domain requires a positive integer chainId, got ${String(e)}`);const n=function(e){return u[e]??null}(e),r=n?.LoanOperationsManagerModule;if(r&&t&&r.toLowerCase()!==t.toLowerCase())throw new Error(`Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${e}: caller ${t}, pinned ${r}`);const i=r??t;if(!i)throw new Error(`No pinned LoanOperationsManagerModule for chainId ${e} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`);return{name:p,version:m,chainId:e,verifyingContract:i}}var h=(e=>(e.SEPOLIA="sepolia",e.ETHEREUM="ethereum",e.HARDHAT="hardhat",e))(h||{}),w={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},y=["infura.io","drpc.org"],b={ethereum:1,sepolia:11155111,hardhat:1337};var A={hardhat:{chain:"hardhat",chainId:b.hardhat,bitcoinNetwork:w.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:b.sepolia,bitcoinNetwork:w.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:2},ethereum:{chain:"ethereum",chainId:b.ethereum,bitcoinNetwork:w.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function E(e){const t=function(e){const t=e.toLowerCase().trim();if("sepolia"===t)return"sepolia";if("ethereum"===t||"mainnet"===t)return"ethereum";if("hardhat"===t)return"hardhat";throw new Error(`Unsupported EVM chain: "${e}". Supported chains: ${Object.values(h).join(", ")}`)}(e),n=A[t];if(!n)throw new Error(`No chain policy registered for "${e}"`);return n}var v=["AgentModuleFactory","AgentDelegationRegistry","BitcoinWithdrawalAddressRegistry"];function I(e,t){if(!e.pinContractAddresses){const e={};for(const n of v){const r=t?.[n];"string"==typeof r&&r.length>0&&(e[n]=r)}return e}const n=(r=e.chainId,c[r]??{});var r;const i={};for(const r of v){const o=n[r];if(!o)continue;const a=t?.[r];if("string"==typeof a&&a.length>0&&a.toLowerCase()!==o.toLowerCase())throw new Error(`Caller-supplied "${r}" (${a}) contradicts the pinned ${e.chain} address (${o}); refusing to evaluate the Safe-agent authorization arm`);i[r]=o}return i}var C=["function execute(address target, bytes calldata data)"],x=["function safe() view returns (address)","function agent() view returns (address)","function isWhitelisted(address target, bytes4 selector) view returns (bool)"],D=["function isFromFactory(address) view returns (bool)"],F={mint:[{signature:"mintUCD(bytes32,uint256,uint256,uint256,uint256,uint256,bytes32,bytes32,bytes32,uint256,bytes)",positionIdPath:"flat"}],repay:[{signature:"approve(address,uint256)",positionIdPath:null},{signature:"makePayment(bytes32,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],renew:[{signature:"extendPosition(bytes32,uint256,uint256,uint256,uint256,uint256,bytes)",positionIdPath:"flat"}],withdraw:[{signature:"withdrawBTC((bytes32,bytes32,bytes32,bytes32,bytes32,string,uint256,uint256,uint256,uint256,string,uint32),bytes,bytes)",positionIdPath:"tuple"}]};var B,P=(e,t)=>"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase();function $(e,t){if("string"!=typeof e||!/^0x[0-9a-fA-F]{40}$/.test(e))throw new Error(`[agent-module-executor] ${t} must be a 0x address, got ${JSON.stringify(e)}`);return e}async function main(e){const t=e?.mode;if("authorize"!==t&&"execute"!==t)throw new Error(`[agent-module-executor] mode must be "authorize" or "execute", got ${JSON.stringify(t)}`);const n=$(e?.safe,"safe"),r=$(e?.module,"module"),i=$(e?.pkpId,"pkpId");if("string"!=typeof e?.positionId||!/^0x[0-9a-fA-F]{64}$/.test(e.positionId))throw new Error("[agent-module-executor] positionId must be a bytes32 hex string");if("string"!=typeof e?.chain||0===e.chain.length)throw new Error('[agent-module-executor] chain is required (e.g. "sepolia")');const s=E(e.chain);if("number"!=typeof e?.chainId||!Number.isInteger(e.chainId))throw new Error("[agent-module-executor] chainId must be an integer");if(e.chainId!==s.chainId)throw new Error(`[agent-module-executor] chainId ${e.chainId} does not match the policy chainId ${s.chainId} derived from chain=${e.chain} \u2014 refusing`);if("string"!=typeof e?.rpcUrl||!e.rpcUrl.startsWith("http"))throw new Error("[agent-module-executor] rpcUrl is required (server-supplied)");!function(e,t){if(e.allowArbitraryEvmRpc)return;if(!t||"string"!=typeof t)throw new Error("validateEvmRpcForPolicy: rpcUrl must be a non-empty string");let n;try{n=new URL(t).hostname}catch(e){throw new Error(`Invalid rpcUrl: ${e?.message??String(e)}`)}if(!y.some((e=>n===e||n.endsWith(`.${e}`))))throw new Error(`Custom RPC domain "${n}" is not in the approved list: ${y.join(", ")}`)}(s,e.rpcUrl);const u=I(s,e?.contractAddresses),c=$(u.AgentDelegationRegistry,"AgentDelegationRegistry (pinned; unavailable on this chain)"),p=$(u.AgentModuleFactory,"AgentModuleFactory (pinned; unavailable on this chain)"),m=new ethers.providers.JsonRpcProvider(e.rpcUrl),l=new ethers.Contract(p,D,m);if(!0!==await l.isFromFactory(r))throw new Error(`[agent-module-executor] module ${r} was not deployed by the canonical AgentModuleFactory ${p} \u2014 refusing to act through an unprovenanced module`);const h=new ethers.Contract(r,x,m),[w,b]=await Promise.all([h.safe(),h.agent()]);if(!P(w,n))throw new Error(`[agent-module-executor] module ${r} is bound to Safe ${w}, not ${n}`);const A=await async function(e){const{provider:t,registryAddress:n,safe:r,positionId:i,op:s,candidateAgent:u}=e,c=new ethers.Contract(n,a,t),p=await c.agentOf(r),m=p.agent??p[0],l=Number(p.status??p[2]),g=Number(p.validUntil??p[1]);if(l!==o)throw new Error(`[agent-authorization] Safe ${r} has no Active agent registration (status=${l}) \u2014 refusing`);if(m.toLowerCase()!==u.toLowerCase())throw new Error(`[agent-authorization] Safe ${r}'s registered agent is ${m}, but ${u} was supplied \u2014 refusing to sign with a key that is merely group-co-member`);if(!Number.isFinite(g)||0===g)throw new Error(`[agent-authorization] agent record for ${r} has no validUntil`);const f="mint"===s?"canMint":"repay"===s?"canRepay":"renew"===s?"canRenew":"withdraw"===s?"canWithdraw":null;if(!f)throw new Error(`[agent-authorization] unknown op ${String(s)}`);const h=await c[f](i,m),w=h.ok??h[0],y=h.reason??h[1];if(!0!==w)throw new Error(`[agent-authorization] registry refused ${s} for position ${i} (agent ${m}): ${d(y)}`);const b=h.effectiveFloorBps??h[2];return{agent:m,validUntil:g,effectiveFloorBps:void 0!==b?Number(b):void 0}}({provider:m,registryAddress:c,safe:n,positionId:e.positionId,op:e.op,candidateAgent:i});if(!P(b,i))throw new Error(`[agent-module-executor] module agent is ${b} but pkpId ${i} was supplied \u2014 refusing to sign with a key the module does not recognise`);const v=await Lit.Actions.getPrivateKey({pkpId:i}),B="string"==typeof v?v.startsWith("0x")?v:`0x${v}`:String(v),R=new ethers.Wallet(B);if(!P(R.address,i))throw new Error(`[agent-module-executor] getPrivateKey returned a key for ${R.address}, not ${i}`);const T={success:!0,mode:t,module:r,agent:A.agent,op:e.op};if("authorize"===t){if("number"!=typeof e.timestamp||!Number.isInteger(e.timestamp))throw new Error("[agent-module-executor] timestamp is required for mode=authorize (quantum-aligned)");const{domain:t,types:n,message:r}=function(e){const t=f(e.chainId,e.contractAddresses?.LoanOperationsManagerModule);if("renew"===e.op){if("number"!=typeof e.selectedTerm)throw new Error("[agent-module-executor] selectedTerm is required for op=renew");return{domain:t,types:g("RenewRequest"),message:{positionId:e.positionId,selectedTerm:e.selectedTerm,quantumTimestamp:e.timestamp}}}if("string"!=typeof e.amount||0===e.amount.length)throw new Error(`[agent-module-executor] amount is required for op=${e.op}`);if("withdraw"===e.op){if("string"!=typeof e.destinationAddress||0===e.destinationAddress.length)throw new Error("[agent-module-executor] destinationAddress is required for op=withdraw");return{domain:t,types:g("WithdrawRequest"),message:{positionId:e.positionId,totalDeduction:e.amount,withdrawalAddress:e.destinationAddress,quantumTimestamp:e.timestamp}}}const n="mint"===e.op?"MintRequest":"RepayRequest";return{domain:t,types:g(n),message:{positionId:e.positionId,["mint"===e.op?"mintAmount":"paymentAmount"]:e.amount,quantumTimestamp:e.timestamp}}}(e),i=await R._signTypedData(t,n,r);return{...T,authorization:{timestamp:e.timestamp,signature:i,signer:R.address}}}const N=$(e?.target,"target");if("string"!=typeof e?.innerData||!/^0x[0-9a-fA-F]{8,}$/.test(e.innerData))throw new Error("[agent-module-executor] innerData must be 0x-hex with a 4-byte selector for mode=execute");const O=e?.tx;if(!O||"number"!=typeof O.nonce||!Number.isInteger(O.nonce)||"string"!=typeof O.gasLimit||"string"!=typeof O.maxFeePerGas||"string"!=typeof O.maxPriorityFeePerGas)throw new Error("[agent-module-executor] tx.{nonce,gasLimit,maxFeePerGas,maxPriorityFeePerGas} are required for mode=execute and must be caller-supplied (multi-node determinism)");const L=e.innerData.slice(0,10);if(!0!==await h.isWhitelisted(N,L))throw new Error(`[agent-module-executor] (${N}, ${L}) is not on module ${r}'s whitelist \u2014 refusing`);const M=(F[e.op]??[]).find((e=>{return(t=e.signature,ethers.utils.id(t).slice(0,10)).toLowerCase()===L.toLowerCase();var t}));if(!M)throw new Error(`[agent-module-executor] op=${e.op} does not authorize selector ${L}. createPosition, setPositionDelegate, and approve-outside-a-repay-grant have no corresponding AgentDelegationRegistry scope and are never reachable through this action (setPositionDelegate specifically: vigil concern C-43) \u2014 refusing to sign`);if(null!==M.positionIdPath){const t=M.signature.slice(0,M.signature.indexOf("(")),n=new ethers.utils.Interface([`function ${M.signature}`]).decodeFunctionData(t,e.innerData),r="tuple"===M.positionIdPath?n[0][0]:n[0];if(!P(r,e.positionId))throw new Error(`[agent-module-executor] innerData targets position ${r}, but the scope grant checked in step 3 was for ${e.positionId} \u2014 refusing to sign a call against a different position than the one authorized`)}const _=new ethers.utils.Interface(C).encodeFunctionData("execute",[N,e.innerData]),q=await R.signTransaction({to:r,data:_,value:0,chainId:e.chainId,nonce:O.nonce,gasLimit:ethers.BigNumber.from(O.gasLimit),maxFeePerGas:ethers.BigNumber.from(O.maxFeePerGas),maxPriorityFeePerGas:ethers.BigNumber.from(O.maxPriorityFeePerGas),type:2});return{...T,signedTransaction:q}}return B=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let d of n(o))r.call(i,d)||d===a||e(i,d,{get:()=>o[d],enumerable:!(s=t(o,d))||s.enumerable});return i})(e({},"__esModule",{value:!0}),B)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e
|