@opendatalabs/vana-sdk 0.1.0-alpha.1bbb6d4 → 0.1.0-alpha.273dc39
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 +42 -0
- package/dist/chains.browser.cjs +2 -2
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.js +2 -2
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +2 -2
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.js +2 -2
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +2 -2
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.js +2 -2
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +861 -160
- package/dist/index.browser.js +1802 -693
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +1824 -714
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +889 -165
- package/dist/index.node.d.ts +889 -165
- package/dist/index.node.js +1809 -700
- package/dist/index.node.js.map +1 -1
- package/package.json +11 -10
package/dist/index.node.cjs
CHANGED
|
@@ -543,6 +543,7 @@ __export(index_node_exports, {
|
|
|
543
543
|
SignatureError: () => SignatureError,
|
|
544
544
|
StorageError: () => StorageError,
|
|
545
545
|
StorageManager: () => StorageManager,
|
|
546
|
+
TransactionHandle: () => TransactionHandle,
|
|
546
547
|
UserRejectedRequestError: () => UserRejectedRequestError,
|
|
547
548
|
Vana: () => Vana,
|
|
548
549
|
VanaCore: () => VanaCore,
|
|
@@ -1285,12 +1286,486 @@ var PermissionError = class extends VanaError {
|
|
|
1285
1286
|
}
|
|
1286
1287
|
};
|
|
1287
1288
|
|
|
1288
|
-
// src/utils/
|
|
1289
|
+
// src/utils/multicall.ts
|
|
1289
1290
|
var import_viem = require("viem");
|
|
1290
1291
|
|
|
1292
|
+
// src/config/addresses.ts
|
|
1293
|
+
var CONTRACTS = {
|
|
1294
|
+
// Data Portability Contracts (New Architecture)
|
|
1295
|
+
DataPortabilityPermissions: {
|
|
1296
|
+
addresses: {
|
|
1297
|
+
14800: "0xD54523048AdD05b4d734aFaE7C68324Ebb7373eF",
|
|
1298
|
+
1480: "0xD54523048AdD05b4d734aFaE7C68324Ebb7373eF"
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1301
|
+
DataPortabilityServers: {
|
|
1302
|
+
addresses: {
|
|
1303
|
+
14800: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c",
|
|
1304
|
+
1480: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c"
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
DataPortabilityGrantees: {
|
|
1308
|
+
addresses: {
|
|
1309
|
+
14800: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234",
|
|
1310
|
+
1480: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234"
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
DataRegistry: {
|
|
1314
|
+
addresses: {
|
|
1315
|
+
14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
|
|
1316
|
+
1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
TeePoolPhala: {
|
|
1320
|
+
addresses: {
|
|
1321
|
+
14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
|
|
1322
|
+
1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
ComputeEngine: {
|
|
1326
|
+
addresses: {
|
|
1327
|
+
14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
|
|
1328
|
+
1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
// Data Access Infrastructure
|
|
1332
|
+
DataRefinerRegistry: {
|
|
1333
|
+
addresses: {
|
|
1334
|
+
14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
|
|
1335
|
+
1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
QueryEngine: {
|
|
1339
|
+
addresses: {
|
|
1340
|
+
14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
|
|
1341
|
+
1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1344
|
+
VanaTreasury: {
|
|
1345
|
+
addresses: {
|
|
1346
|
+
14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
|
|
1347
|
+
1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
|
|
1348
|
+
}
|
|
1349
|
+
},
|
|
1350
|
+
ComputeInstructionRegistry: {
|
|
1351
|
+
addresses: {
|
|
1352
|
+
14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
|
|
1353
|
+
1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
|
|
1354
|
+
}
|
|
1355
|
+
},
|
|
1356
|
+
// TEE Pool Variants
|
|
1357
|
+
TeePoolEphemeralStandard: {
|
|
1358
|
+
addresses: {
|
|
1359
|
+
14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
|
|
1360
|
+
1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
TeePoolPersistentStandard: {
|
|
1364
|
+
addresses: {
|
|
1365
|
+
14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
|
|
1366
|
+
1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
TeePoolPersistentGpu: {
|
|
1370
|
+
addresses: {
|
|
1371
|
+
14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
|
|
1372
|
+
1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
TeePoolDedicatedStandard: {
|
|
1376
|
+
addresses: {
|
|
1377
|
+
14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
|
|
1378
|
+
1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
|
|
1379
|
+
}
|
|
1380
|
+
},
|
|
1381
|
+
TeePoolDedicatedGpu: {
|
|
1382
|
+
addresses: {
|
|
1383
|
+
14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
|
|
1384
|
+
1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
|
|
1385
|
+
}
|
|
1386
|
+
},
|
|
1387
|
+
// DLP Reward System
|
|
1388
|
+
VanaEpoch: {
|
|
1389
|
+
addresses: {
|
|
1390
|
+
14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
|
|
1391
|
+
1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
DLPRegistry: {
|
|
1395
|
+
addresses: {
|
|
1396
|
+
14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
|
|
1397
|
+
1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
DLPRegistryTreasury: {
|
|
1401
|
+
addresses: {
|
|
1402
|
+
14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
|
|
1403
|
+
1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
DLPPerformance: {
|
|
1407
|
+
addresses: {
|
|
1408
|
+
14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
|
|
1409
|
+
1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
DLPRewardDeployer: {
|
|
1413
|
+
addresses: {
|
|
1414
|
+
14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
|
|
1415
|
+
1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
DLPRewardDeployerTreasury: {
|
|
1419
|
+
addresses: {
|
|
1420
|
+
14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
|
|
1421
|
+
1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
DLPRewardSwap: {
|
|
1425
|
+
addresses: {
|
|
1426
|
+
14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
|
|
1427
|
+
1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
SwapHelper: {
|
|
1431
|
+
addresses: {
|
|
1432
|
+
14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
|
|
1433
|
+
1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
|
|
1434
|
+
}
|
|
1435
|
+
},
|
|
1436
|
+
// VanaPool (Staking)
|
|
1437
|
+
VanaPoolStaking: {
|
|
1438
|
+
addresses: {
|
|
1439
|
+
14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
|
|
1440
|
+
1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
VanaPoolEntity: {
|
|
1444
|
+
addresses: {
|
|
1445
|
+
14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
|
|
1446
|
+
1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
VanaPoolTreasury: {
|
|
1450
|
+
addresses: {
|
|
1451
|
+
14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
|
|
1452
|
+
1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1455
|
+
// DLP Deployment Contracts
|
|
1456
|
+
DAT: {
|
|
1457
|
+
addresses: {
|
|
1458
|
+
14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
|
|
1459
|
+
1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
|
|
1460
|
+
}
|
|
1461
|
+
},
|
|
1462
|
+
DATFactory: {
|
|
1463
|
+
addresses: {
|
|
1464
|
+
14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
|
|
1465
|
+
1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
|
|
1466
|
+
}
|
|
1467
|
+
},
|
|
1468
|
+
DATPausable: {
|
|
1469
|
+
addresses: {
|
|
1470
|
+
14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
|
|
1471
|
+
1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
DATVotes: {
|
|
1475
|
+
addresses: {
|
|
1476
|
+
14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
|
|
1477
|
+
1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
// Utility Contracts (no ABIs in SDK)
|
|
1481
|
+
Multicall3: {
|
|
1482
|
+
addresses: {
|
|
1483
|
+
14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
|
|
1484
|
+
1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
Multisend: {
|
|
1488
|
+
addresses: {
|
|
1489
|
+
14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
|
|
1490
|
+
1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
var LEGACY_CONTRACTS = {
|
|
1495
|
+
// DEPRECATED: Original Intel SGX TeePool (PRO-347)
|
|
1496
|
+
TeePool: {
|
|
1497
|
+
addresses: {
|
|
1498
|
+
14800: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D",
|
|
1499
|
+
1480: "0x3c92fD91639b41f13338CE62f19131e7d19eaa0D"
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
// DEPRECATED: DLPRoot system (replaced by VanaPool + DLPRewards)
|
|
1503
|
+
DLPRootEpoch: {
|
|
1504
|
+
addresses: {
|
|
1505
|
+
14800: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F",
|
|
1506
|
+
1480: "0xc3d176cF6BccFCB9225b53B87a95147218e1537F"
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
DLPRootCore: {
|
|
1510
|
+
addresses: {
|
|
1511
|
+
14800: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD",
|
|
1512
|
+
1480: "0x0aBa5e28228c323A67712101d61a54d4ff5720FD"
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
DLPRoot: {
|
|
1516
|
+
addresses: {
|
|
1517
|
+
14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
|
|
1518
|
+
1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
DLPRootMetrics: {
|
|
1522
|
+
addresses: {
|
|
1523
|
+
14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
|
|
1524
|
+
1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
DLPRootStakesTreasury: {
|
|
1528
|
+
addresses: {
|
|
1529
|
+
14800: "0x52c3260ED5C235fcA43524CF508e29c897318775",
|
|
1530
|
+
1480: "0x52c3260ED5C235fcA43524CF508e29c897318775"
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
DLPRootRewardsTreasury: {
|
|
1534
|
+
addresses: {
|
|
1535
|
+
14800: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479",
|
|
1536
|
+
1480: "0xDBFb6B8b9E2eCAEbdE64d665cD553dB81e524479"
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
var CONTRACT_ADDRESSES = {
|
|
1541
|
+
14800: Object.fromEntries(
|
|
1542
|
+
Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
|
|
1543
|
+
),
|
|
1544
|
+
1480: Object.fromEntries(
|
|
1545
|
+
Object.entries(CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
|
|
1546
|
+
)
|
|
1547
|
+
};
|
|
1548
|
+
var UTILITY_ADDRESSES = {
|
|
1549
|
+
14800: {
|
|
1550
|
+
Multicall3: CONTRACTS.Multicall3.addresses[14800],
|
|
1551
|
+
Multisend: CONTRACTS.Multisend.addresses[14800]
|
|
1552
|
+
},
|
|
1553
|
+
1480: {
|
|
1554
|
+
Multicall3: CONTRACTS.Multicall3.addresses[1480],
|
|
1555
|
+
Multisend: CONTRACTS.Multisend.addresses[1480]
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
var LEGACY_ADDRESSES = {
|
|
1559
|
+
14800: Object.fromEntries(
|
|
1560
|
+
Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[14800]]).filter(([, addr]) => addr)
|
|
1561
|
+
),
|
|
1562
|
+
1480: Object.fromEntries(
|
|
1563
|
+
Object.entries(LEGACY_CONTRACTS).map(([name, info]) => [name, info.addresses[1480]]).filter(([, addr]) => addr)
|
|
1564
|
+
)
|
|
1565
|
+
};
|
|
1566
|
+
var getContractAddress = (chainId, contract) => {
|
|
1567
|
+
const contractAddress = CONTRACT_ADDRESSES[chainId]?.[contract];
|
|
1568
|
+
if (!contractAddress) {
|
|
1569
|
+
throw new Error(
|
|
1570
|
+
`Contract address not found for ${contract} on chain ${chainId}`
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
return contractAddress;
|
|
1574
|
+
};
|
|
1575
|
+
var getUtilityAddress = (chainId, contract) => {
|
|
1576
|
+
return UTILITY_ADDRESSES[chainId][contract];
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
// src/utils/multicall.ts
|
|
1580
|
+
var DEFAULT_OPTIONS = {
|
|
1581
|
+
maxGasPerBatch: 10000000n,
|
|
1582
|
+
// 10M gas - conservative default
|
|
1583
|
+
maxCalldataBytes: 1e5,
|
|
1584
|
+
// 100KB - works with most RPC providers
|
|
1585
|
+
checkpointFrequency: {
|
|
1586
|
+
calls: 32,
|
|
1587
|
+
bytes: 8192
|
|
1588
|
+
// 8KB
|
|
1589
|
+
},
|
|
1590
|
+
allowFailure: false
|
|
1591
|
+
};
|
|
1592
|
+
async function gasAwareMulticall(client, parameters, options = {}) {
|
|
1593
|
+
const chainId = await client.getChainId();
|
|
1594
|
+
const multicall3Address = options.multicallAddress || getUtilityAddress(chainId, "Multicall3");
|
|
1595
|
+
const opts = {
|
|
1596
|
+
...DEFAULT_OPTIONS,
|
|
1597
|
+
...options,
|
|
1598
|
+
multicallAddress: multicall3Address,
|
|
1599
|
+
checkpointFrequency: {
|
|
1600
|
+
...DEFAULT_OPTIONS.checkpointFrequency,
|
|
1601
|
+
...options.checkpointFrequency
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
if (parameters.allowFailure !== void 0) {
|
|
1605
|
+
opts.allowFailure = parameters.allowFailure;
|
|
1606
|
+
}
|
|
1607
|
+
const { contracts } = parameters;
|
|
1608
|
+
if (!contracts || contracts.length === 0) {
|
|
1609
|
+
return [];
|
|
1610
|
+
}
|
|
1611
|
+
const batches = await createBatches(
|
|
1612
|
+
client,
|
|
1613
|
+
contracts,
|
|
1614
|
+
opts
|
|
1615
|
+
);
|
|
1616
|
+
const batchResults = await Promise.all(
|
|
1617
|
+
batches.map((batch, index) => {
|
|
1618
|
+
if (opts.onProgress && index > 0) {
|
|
1619
|
+
const completed = batches.slice(0, index).reduce((sum, b) => sum + b.length, 0);
|
|
1620
|
+
opts.onProgress(completed, contracts.length);
|
|
1621
|
+
}
|
|
1622
|
+
return client.multicall({
|
|
1623
|
+
...parameters,
|
|
1624
|
+
contracts: batch,
|
|
1625
|
+
multicallAddress: opts.multicallAddress,
|
|
1626
|
+
allowFailure: opts.allowFailure
|
|
1627
|
+
});
|
|
1628
|
+
})
|
|
1629
|
+
);
|
|
1630
|
+
if (opts.onProgress) {
|
|
1631
|
+
opts.onProgress(contracts.length, contracts.length);
|
|
1632
|
+
}
|
|
1633
|
+
return batchResults.flat();
|
|
1634
|
+
}
|
|
1635
|
+
async function createBatches(client, contracts, options) {
|
|
1636
|
+
const batches = [];
|
|
1637
|
+
let currentBatch = [];
|
|
1638
|
+
let currentBytes = 0;
|
|
1639
|
+
let lastCheckpointIndex = 0;
|
|
1640
|
+
let lastCheckpointBytes = 0;
|
|
1641
|
+
let lastEstimatedGas = 0n;
|
|
1642
|
+
for (let i = 0; i < contracts.length; i++) {
|
|
1643
|
+
const contract = contracts[i];
|
|
1644
|
+
const encoded = encodeContractCall(contract);
|
|
1645
|
+
const callBytes = (0, import_viem.size)(encoded);
|
|
1646
|
+
const callsSinceCheckpoint = i - lastCheckpointIndex;
|
|
1647
|
+
const bytesSinceCheckpoint = currentBytes - lastCheckpointBytes;
|
|
1648
|
+
const needsCheckpoint = callsSinceCheckpoint >= options.checkpointFrequency.calls || bytesSinceCheckpoint >= options.checkpointFrequency.bytes;
|
|
1649
|
+
if (needsCheckpoint && currentBatch.length > 0) {
|
|
1650
|
+
try {
|
|
1651
|
+
lastEstimatedGas = await estimateBatchGas(
|
|
1652
|
+
client,
|
|
1653
|
+
currentBatch,
|
|
1654
|
+
options.multicallAddress
|
|
1655
|
+
);
|
|
1656
|
+
lastCheckpointIndex = i;
|
|
1657
|
+
lastCheckpointBytes = currentBytes;
|
|
1658
|
+
} catch (error) {
|
|
1659
|
+
if (currentBatch.length > 1) {
|
|
1660
|
+
const halfBatch = currentBatch.slice(
|
|
1661
|
+
0,
|
|
1662
|
+
Math.floor(currentBatch.length / 2)
|
|
1663
|
+
);
|
|
1664
|
+
batches.push(halfBatch);
|
|
1665
|
+
currentBatch = currentBatch.slice(halfBatch.length);
|
|
1666
|
+
currentBytes = calculateBatchSize(currentBatch);
|
|
1667
|
+
lastCheckpointIndex = i;
|
|
1668
|
+
lastCheckpointBytes = currentBytes;
|
|
1669
|
+
lastEstimatedGas = 0n;
|
|
1670
|
+
} else {
|
|
1671
|
+
if (!options.allowFailure) {
|
|
1672
|
+
throw new Error(`Gas estimation failed for call ${i}: ${error}`);
|
|
1673
|
+
}
|
|
1674
|
+
currentBatch = [];
|
|
1675
|
+
currentBytes = 0;
|
|
1676
|
+
continue;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
const wouldExceedCalldata = currentBytes + callBytes > options.maxCalldataBytes;
|
|
1681
|
+
const wouldExceedGas = lastEstimatedGas > 0n && estimateNextGas(lastEstimatedGas, callsSinceCheckpoint + 1) > options.maxGasPerBatch;
|
|
1682
|
+
if ((wouldExceedCalldata || wouldExceedGas) && currentBatch.length > 0) {
|
|
1683
|
+
batches.push(currentBatch);
|
|
1684
|
+
currentBatch = [];
|
|
1685
|
+
currentBytes = 0;
|
|
1686
|
+
lastCheckpointIndex = i;
|
|
1687
|
+
lastCheckpointBytes = 0;
|
|
1688
|
+
lastEstimatedGas = 0n;
|
|
1689
|
+
}
|
|
1690
|
+
currentBatch.push(contract);
|
|
1691
|
+
currentBytes += callBytes;
|
|
1692
|
+
}
|
|
1693
|
+
if (currentBatch.length > 0) {
|
|
1694
|
+
batches.push(currentBatch);
|
|
1695
|
+
}
|
|
1696
|
+
return batches;
|
|
1697
|
+
}
|
|
1698
|
+
function encodeContractCall(contract) {
|
|
1699
|
+
const { abi, functionName, args } = contract;
|
|
1700
|
+
return (0, import_viem.encodeFunctionData)({
|
|
1701
|
+
abi,
|
|
1702
|
+
functionName,
|
|
1703
|
+
args
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
function calculateBatchSize(batch) {
|
|
1707
|
+
return batch.reduce((total, contract) => {
|
|
1708
|
+
const encoded = encodeContractCall(contract);
|
|
1709
|
+
return total + (0, import_viem.size)(encoded);
|
|
1710
|
+
}, 0);
|
|
1711
|
+
}
|
|
1712
|
+
async function estimateBatchGas(client, batch, multicallAddress) {
|
|
1713
|
+
const calls = batch.map((contract) => ({
|
|
1714
|
+
target: contract.address,
|
|
1715
|
+
allowFailure: false,
|
|
1716
|
+
callData: encodeContractCall(contract)
|
|
1717
|
+
}));
|
|
1718
|
+
const gas = await client.estimateGas({
|
|
1719
|
+
to: multicallAddress,
|
|
1720
|
+
data: (0, import_viem.encodeFunctionData)({
|
|
1721
|
+
abi: multicall3Abi,
|
|
1722
|
+
functionName: "aggregate3",
|
|
1723
|
+
args: [calls]
|
|
1724
|
+
})
|
|
1725
|
+
});
|
|
1726
|
+
return gas;
|
|
1727
|
+
}
|
|
1728
|
+
function estimateNextGas(lastGas, callsSinceCheckpoint) {
|
|
1729
|
+
if (callsSinceCheckpoint === 0) return lastGas;
|
|
1730
|
+
const avgGasPerCall = lastGas / BigInt(Math.max(1, callsSinceCheckpoint - 1));
|
|
1731
|
+
const estimatedGas = lastGas + avgGasPerCall;
|
|
1732
|
+
return estimatedGas * 110n / 100n;
|
|
1733
|
+
}
|
|
1734
|
+
var multicall3Abi = [
|
|
1735
|
+
{
|
|
1736
|
+
name: "aggregate3",
|
|
1737
|
+
type: "function",
|
|
1738
|
+
stateMutability: "payable",
|
|
1739
|
+
inputs: [
|
|
1740
|
+
{
|
|
1741
|
+
name: "calls",
|
|
1742
|
+
type: "tuple[]",
|
|
1743
|
+
components: [
|
|
1744
|
+
{ name: "target", type: "address" },
|
|
1745
|
+
{ name: "allowFailure", type: "bool" },
|
|
1746
|
+
{ name: "callData", type: "bytes" }
|
|
1747
|
+
]
|
|
1748
|
+
}
|
|
1749
|
+
],
|
|
1750
|
+
outputs: [
|
|
1751
|
+
{
|
|
1752
|
+
name: "returnData",
|
|
1753
|
+
type: "tuple[]",
|
|
1754
|
+
components: [
|
|
1755
|
+
{ name: "success", type: "bool" },
|
|
1756
|
+
{ name: "returnData", type: "bytes" }
|
|
1757
|
+
]
|
|
1758
|
+
}
|
|
1759
|
+
]
|
|
1760
|
+
}
|
|
1761
|
+
];
|
|
1762
|
+
|
|
1763
|
+
// src/utils/transactionParsing.ts
|
|
1764
|
+
var import_viem2 = require("viem");
|
|
1765
|
+
|
|
1291
1766
|
// src/config/eventMappings.ts
|
|
1292
1767
|
var EVENT_MAPPINGS = {
|
|
1293
|
-
//
|
|
1768
|
+
// DataPortabilityPermissions operations
|
|
1294
1769
|
grant: {
|
|
1295
1770
|
contract: "DataPortabilityPermissions",
|
|
1296
1771
|
event: "PermissionAdded"
|
|
@@ -1299,6 +1774,15 @@ var EVENT_MAPPINGS = {
|
|
|
1299
1774
|
contract: "DataPortabilityPermissions",
|
|
1300
1775
|
event: "PermissionRevoked"
|
|
1301
1776
|
},
|
|
1777
|
+
revokePermission: {
|
|
1778
|
+
contract: "DataPortabilityPermissions",
|
|
1779
|
+
event: "PermissionRevoked"
|
|
1780
|
+
},
|
|
1781
|
+
addServerFilesAndPermissions: {
|
|
1782
|
+
contract: "DataPortabilityPermissions",
|
|
1783
|
+
event: "PermissionAdded"
|
|
1784
|
+
},
|
|
1785
|
+
// DataPortabilityServers operations
|
|
1302
1786
|
trustServer: {
|
|
1303
1787
|
contract: "DataPortabilityServers",
|
|
1304
1788
|
event: "ServerTrusted"
|
|
@@ -1307,15 +1791,51 @@ var EVENT_MAPPINGS = {
|
|
|
1307
1791
|
contract: "DataPortabilityServers",
|
|
1308
1792
|
event: "ServerUntrusted"
|
|
1309
1793
|
},
|
|
1310
|
-
|
|
1794
|
+
registerServer: {
|
|
1795
|
+
contract: "DataPortabilityServers",
|
|
1796
|
+
event: "ServerRegistered"
|
|
1797
|
+
},
|
|
1798
|
+
updateServer: {
|
|
1799
|
+
contract: "DataPortabilityServers",
|
|
1800
|
+
event: "ServerUpdated"
|
|
1801
|
+
},
|
|
1802
|
+
addAndTrustServer: {
|
|
1803
|
+
contract: "DataPortabilityServers",
|
|
1804
|
+
event: "ServerTrusted"
|
|
1805
|
+
},
|
|
1806
|
+
// DataRegistry operations
|
|
1311
1807
|
addFile: {
|
|
1312
1808
|
contract: "DataRegistry",
|
|
1313
1809
|
event: "FileAdded"
|
|
1314
1810
|
},
|
|
1811
|
+
addFileWithPermissionsAndSchema: {
|
|
1812
|
+
contract: "DataRegistry",
|
|
1813
|
+
event: "FileAdded"
|
|
1814
|
+
},
|
|
1815
|
+
addFileWithSchema: {
|
|
1816
|
+
contract: "DataRegistry",
|
|
1817
|
+
event: "FileAdded"
|
|
1818
|
+
},
|
|
1819
|
+
addFileWithPermissions: {
|
|
1820
|
+
contract: "DataRegistry",
|
|
1821
|
+
event: "FileAdded"
|
|
1822
|
+
},
|
|
1315
1823
|
addRefinement: {
|
|
1316
1824
|
contract: "DataRegistry",
|
|
1317
1825
|
event: "RefinementAdded"
|
|
1318
1826
|
},
|
|
1827
|
+
addRefiner: {
|
|
1828
|
+
contract: "DataRefinerRegistry",
|
|
1829
|
+
event: "RefinerAdded"
|
|
1830
|
+
},
|
|
1831
|
+
updateSchemaId: {
|
|
1832
|
+
contract: "DataRefinerRegistry",
|
|
1833
|
+
event: "SchemaAdded"
|
|
1834
|
+
},
|
|
1835
|
+
addSchema: {
|
|
1836
|
+
contract: "DataRefinerRegistry",
|
|
1837
|
+
event: "SchemaAdded"
|
|
1838
|
+
},
|
|
1319
1839
|
updateRefinement: {
|
|
1320
1840
|
contract: "DataRegistry",
|
|
1321
1841
|
event: "RefinementUpdated"
|
|
@@ -1323,10 +1843,15 @@ var EVENT_MAPPINGS = {
|
|
|
1323
1843
|
addFilePermission: {
|
|
1324
1844
|
contract: "DataRegistry",
|
|
1325
1845
|
event: "PermissionGranted"
|
|
1846
|
+
},
|
|
1847
|
+
// DataPortabilityGrantees operations
|
|
1848
|
+
registerGrantee: {
|
|
1849
|
+
contract: "DataPortabilityGrantees",
|
|
1850
|
+
event: "GranteeRegistered"
|
|
1326
1851
|
}
|
|
1327
1852
|
};
|
|
1328
1853
|
|
|
1329
|
-
// src/abi/ComputeEngineImplementation.ts
|
|
1854
|
+
// src/generated/abi/ComputeEngineImplementation.ts
|
|
1330
1855
|
var ComputeEngineABI = [
|
|
1331
1856
|
{
|
|
1332
1857
|
inputs: [],
|
|
@@ -2611,7 +3136,7 @@ var ComputeEngineABI = [
|
|
|
2611
3136
|
}
|
|
2612
3137
|
];
|
|
2613
3138
|
|
|
2614
|
-
// src/abi/DataRegistryImplementation.ts
|
|
3139
|
+
// src/generated/abi/DataRegistryImplementation.ts
|
|
2615
3140
|
var DataRegistryABI = [
|
|
2616
3141
|
{
|
|
2617
3142
|
inputs: [],
|
|
@@ -3801,7 +4326,7 @@ var DataRegistryABI = [
|
|
|
3801
4326
|
}
|
|
3802
4327
|
];
|
|
3803
4328
|
|
|
3804
|
-
// src/abi/TeePoolImplementation.ts
|
|
4329
|
+
// src/generated/abi/TeePoolImplementation.ts
|
|
3805
4330
|
var TeePoolABI = [
|
|
3806
4331
|
{
|
|
3807
4332
|
inputs: [],
|
|
@@ -5086,7 +5611,7 @@ var TeePoolABI = [
|
|
|
5086
5611
|
}
|
|
5087
5612
|
];
|
|
5088
5613
|
|
|
5089
|
-
// src/abi/TeePoolPhalaImplementation.ts
|
|
5614
|
+
// src/generated/abi/TeePoolPhalaImplementation.ts
|
|
5090
5615
|
var TeePoolPhalaABI = [
|
|
5091
5616
|
{
|
|
5092
5617
|
inputs: [],
|
|
@@ -6371,7 +6896,7 @@ var TeePoolPhalaABI = [
|
|
|
6371
6896
|
}
|
|
6372
6897
|
];
|
|
6373
6898
|
|
|
6374
|
-
// src/abi/DataPortabilityPermissionsImplementation.ts
|
|
6899
|
+
// src/generated/abi/DataPortabilityPermissionsImplementation.ts
|
|
6375
6900
|
var DataPortabilityPermissionsABI = [
|
|
6376
6901
|
{
|
|
6377
6902
|
inputs: [],
|
|
@@ -7639,7 +8164,7 @@ var DataPortabilityPermissionsABI = [
|
|
|
7639
8164
|
}
|
|
7640
8165
|
];
|
|
7641
8166
|
|
|
7642
|
-
// src/abi/DataPortabilityServersImplementation.ts
|
|
8167
|
+
// src/generated/abi/DataPortabilityServersImplementation.ts
|
|
7643
8168
|
var DataPortabilityServersABI = [
|
|
7644
8169
|
{
|
|
7645
8170
|
inputs: [],
|
|
@@ -9031,7 +9556,7 @@ var DataPortabilityServersABI = [
|
|
|
9031
9556
|
}
|
|
9032
9557
|
];
|
|
9033
9558
|
|
|
9034
|
-
// src/abi/DataPortabilityGranteesImplementation.ts
|
|
9559
|
+
// src/generated/abi/DataPortabilityGranteesImplementation.ts
|
|
9035
9560
|
var DataPortabilityGranteesABI = [
|
|
9036
9561
|
{
|
|
9037
9562
|
inputs: [],
|
|
@@ -9891,7 +10416,7 @@ var DataPortabilityGranteesABI = [
|
|
|
9891
10416
|
}
|
|
9892
10417
|
];
|
|
9893
10418
|
|
|
9894
|
-
// src/abi/DataRefinerRegistryImplementation.ts
|
|
10419
|
+
// src/generated/abi/DataRefinerRegistryImplementation.ts
|
|
9895
10420
|
var DataRefinerRegistryABI = [
|
|
9896
10421
|
{
|
|
9897
10422
|
inputs: [],
|
|
@@ -10847,7 +11372,7 @@ var DataRefinerRegistryABI = [
|
|
|
10847
11372
|
}
|
|
10848
11373
|
];
|
|
10849
11374
|
|
|
10850
|
-
// src/abi/QueryEngineImplementation.ts
|
|
11375
|
+
// src/generated/abi/QueryEngineImplementation.ts
|
|
10851
11376
|
var QueryEngineABI = [
|
|
10852
11377
|
{
|
|
10853
11378
|
inputs: [],
|
|
@@ -12138,7 +12663,7 @@ var QueryEngineABI = [
|
|
|
12138
12663
|
}
|
|
12139
12664
|
];
|
|
12140
12665
|
|
|
12141
|
-
// src/abi/ComputeInstructionRegistryImplementation.ts
|
|
12666
|
+
// src/generated/abi/ComputeInstructionRegistryImplementation.ts
|
|
12142
12667
|
var ComputeInstructionRegistryABI = [
|
|
12143
12668
|
{
|
|
12144
12669
|
inputs: [],
|
|
@@ -12844,7 +13369,7 @@ var ComputeInstructionRegistryABI = [
|
|
|
12844
13369
|
}
|
|
12845
13370
|
];
|
|
12846
13371
|
|
|
12847
|
-
// src/abi/TeePoolEphemeralStandardImplementation.ts
|
|
13372
|
+
// src/generated/abi/TeePoolEphemeralStandardImplementation.ts
|
|
12848
13373
|
var TeePoolEphemeralStandardABI = [
|
|
12849
13374
|
{
|
|
12850
13375
|
inputs: [],
|
|
@@ -13752,7 +14277,7 @@ var TeePoolEphemeralStandardABI = [
|
|
|
13752
14277
|
}
|
|
13753
14278
|
];
|
|
13754
14279
|
|
|
13755
|
-
// src/abi/TeePoolPersistentStandardImplementation.ts
|
|
14280
|
+
// src/generated/abi/TeePoolPersistentStandardImplementation.ts
|
|
13756
14281
|
var TeePoolPersistentStandardABI = [
|
|
13757
14282
|
{
|
|
13758
14283
|
inputs: [],
|
|
@@ -14660,7 +15185,7 @@ var TeePoolPersistentStandardABI = [
|
|
|
14660
15185
|
}
|
|
14661
15186
|
];
|
|
14662
15187
|
|
|
14663
|
-
// src/abi/TeePoolPersistentGpuImplementation.ts
|
|
15188
|
+
// src/generated/abi/TeePoolPersistentGpuImplementation.ts
|
|
14664
15189
|
var TeePoolPersistentGpuABI = [
|
|
14665
15190
|
{
|
|
14666
15191
|
inputs: [],
|
|
@@ -15568,7 +16093,7 @@ var TeePoolPersistentGpuABI = [
|
|
|
15568
16093
|
}
|
|
15569
16094
|
];
|
|
15570
16095
|
|
|
15571
|
-
// src/abi/TeePoolDedicatedStandardImplementation.ts
|
|
16096
|
+
// src/generated/abi/TeePoolDedicatedStandardImplementation.ts
|
|
15572
16097
|
var TeePoolDedicatedStandardABI = [
|
|
15573
16098
|
{
|
|
15574
16099
|
inputs: [],
|
|
@@ -16476,7 +17001,7 @@ var TeePoolDedicatedStandardABI = [
|
|
|
16476
17001
|
}
|
|
16477
17002
|
];
|
|
16478
17003
|
|
|
16479
|
-
// src/abi/TeePoolDedicatedGpuImplementation.ts
|
|
17004
|
+
// src/generated/abi/TeePoolDedicatedGpuImplementation.ts
|
|
16480
17005
|
var TeePoolDedicatedGpuABI = [
|
|
16481
17006
|
{
|
|
16482
17007
|
inputs: [],
|
|
@@ -17384,7 +17909,7 @@ var TeePoolDedicatedGpuABI = [
|
|
|
17384
17909
|
}
|
|
17385
17910
|
];
|
|
17386
17911
|
|
|
17387
|
-
// src/abi/VanaEpochImplementation.ts
|
|
17912
|
+
// src/generated/abi/VanaEpochImplementation.ts
|
|
17388
17913
|
var VanaEpochABI = [
|
|
17389
17914
|
{
|
|
17390
17915
|
inputs: [],
|
|
@@ -18544,7 +19069,7 @@ var VanaEpochABI = [
|
|
|
18544
19069
|
}
|
|
18545
19070
|
];
|
|
18546
19071
|
|
|
18547
|
-
// src/abi/DLPRegistryImplementation.ts
|
|
19072
|
+
// src/generated/abi/DLPRegistryImplementation.ts
|
|
18548
19073
|
var DLPRegistryABI = [
|
|
18549
19074
|
{
|
|
18550
19075
|
inputs: [],
|
|
@@ -19985,7 +20510,7 @@ var DLPRegistryABI = [
|
|
|
19985
20510
|
}
|
|
19986
20511
|
];
|
|
19987
20512
|
|
|
19988
|
-
// src/abi/DLPTreasuryImplementation.ts
|
|
20513
|
+
// src/generated/abi/DLPTreasuryImplementation.ts
|
|
19989
20514
|
var DLPRegistryTreasuryABI = [
|
|
19990
20515
|
{
|
|
19991
20516
|
inputs: [],
|
|
@@ -20569,7 +21094,7 @@ var DLPRegistryTreasuryABI = [
|
|
|
20569
21094
|
}
|
|
20570
21095
|
];
|
|
20571
21096
|
|
|
20572
|
-
// src/abi/DLPRewardDeployerTreasuryImplementation.ts
|
|
21097
|
+
// src/generated/abi/DLPRewardDeployerTreasuryImplementation.ts
|
|
20573
21098
|
var DLPRewardDeployerTreasuryABI = [
|
|
20574
21099
|
{
|
|
20575
21100
|
inputs: [],
|
|
@@ -21153,7 +21678,7 @@ var DLPRewardDeployerTreasuryABI = [
|
|
|
21153
21678
|
}
|
|
21154
21679
|
];
|
|
21155
21680
|
|
|
21156
|
-
// src/abi/DLPPerformanceImplementation.ts
|
|
21681
|
+
// src/generated/abi/DLPPerformanceImplementation.ts
|
|
21157
21682
|
var DLPPerformanceABI = [
|
|
21158
21683
|
{
|
|
21159
21684
|
inputs: [],
|
|
@@ -22285,7 +22810,7 @@ var DLPPerformanceABI = [
|
|
|
22285
22810
|
}
|
|
22286
22811
|
];
|
|
22287
22812
|
|
|
22288
|
-
// src/abi/DLPRewardDeployerImplementation.ts
|
|
22813
|
+
// src/generated/abi/DLPRewardDeployerImplementation.ts
|
|
22289
22814
|
var DLPRewardDeployerABI = [
|
|
22290
22815
|
{
|
|
22291
22816
|
inputs: [],
|
|
@@ -23205,7 +23730,7 @@ var DLPRewardDeployerABI = [
|
|
|
23205
23730
|
}
|
|
23206
23731
|
];
|
|
23207
23732
|
|
|
23208
|
-
// src/abi/DLPRewardSwapImplementation.ts
|
|
23733
|
+
// src/generated/abi/DLPRewardSwapImplementation.ts
|
|
23209
23734
|
var DLPRewardSwapABI = [
|
|
23210
23735
|
{
|
|
23211
23736
|
inputs: [],
|
|
@@ -24116,7 +24641,7 @@ var DLPRewardSwapABI = [
|
|
|
24116
24641
|
}
|
|
24117
24642
|
];
|
|
24118
24643
|
|
|
24119
|
-
// src/abi/SwapHelperImplementation.ts
|
|
24644
|
+
// src/generated/abi/SwapHelperImplementation.ts
|
|
24120
24645
|
var SwapHelperABI = [
|
|
24121
24646
|
{
|
|
24122
24647
|
inputs: [],
|
|
@@ -25107,7 +25632,7 @@ var SwapHelperABI = [
|
|
|
25107
25632
|
}
|
|
25108
25633
|
];
|
|
25109
25634
|
|
|
25110
|
-
// src/abi/DLPRootImplementation.ts
|
|
25635
|
+
// src/generated/abi/DLPRootImplementation.ts
|
|
25111
25636
|
var DLPRootImplementation2Abi = [
|
|
25112
25637
|
{
|
|
25113
25638
|
inputs: [],
|
|
@@ -26725,7 +27250,7 @@ var DLPRootImplementation2Abi = [
|
|
|
26725
27250
|
}
|
|
26726
27251
|
];
|
|
26727
27252
|
|
|
26728
|
-
// src/abi/DataLiquidityPoolImplementation.ts
|
|
27253
|
+
// src/generated/abi/DataLiquidityPoolImplementation.ts
|
|
26729
27254
|
var DataLiquidityPoolImplementationAbi = [
|
|
26730
27255
|
{
|
|
26731
27256
|
inputs: [],
|
|
@@ -27684,7 +28209,7 @@ var DataLiquidityPoolImplementationAbi = [
|
|
|
27684
28209
|
}
|
|
27685
28210
|
];
|
|
27686
28211
|
|
|
27687
|
-
// src/abi/DLPRegistryTreasuryImplementation.ts
|
|
28212
|
+
// src/generated/abi/DLPRegistryTreasuryImplementation.ts
|
|
27688
28213
|
var DLPRegistryTreasuryABI2 = [
|
|
27689
28214
|
{
|
|
27690
28215
|
inputs: [],
|
|
@@ -28268,7 +28793,7 @@ var DLPRegistryTreasuryABI2 = [
|
|
|
28268
28793
|
}
|
|
28269
28794
|
];
|
|
28270
28795
|
|
|
28271
|
-
// src/abi/VanaPoolStakingImplementation.ts
|
|
28796
|
+
// src/generated/abi/VanaPoolStakingImplementation.ts
|
|
28272
28797
|
var VanaPoolStakingABI = [
|
|
28273
28798
|
{
|
|
28274
28799
|
inputs: [],
|
|
@@ -29161,7 +29686,7 @@ var VanaPoolStakingABI = [
|
|
|
29161
29686
|
}
|
|
29162
29687
|
];
|
|
29163
29688
|
|
|
29164
|
-
// src/abi/VanaPoolEntityImplementation.ts
|
|
29689
|
+
// src/generated/abi/VanaPoolEntityImplementation.ts
|
|
29165
29690
|
var VanaPoolEntityABI = [
|
|
29166
29691
|
{
|
|
29167
29692
|
inputs: [],
|
|
@@ -30367,7 +30892,7 @@ var VanaPoolEntityABI = [
|
|
|
30367
30892
|
}
|
|
30368
30893
|
];
|
|
30369
30894
|
|
|
30370
|
-
// src/abi/VanaPoolTreasuryImplementation.ts
|
|
30895
|
+
// src/generated/abi/VanaPoolTreasuryImplementation.ts
|
|
30371
30896
|
var VanaPoolTreasuryABI = [
|
|
30372
30897
|
{
|
|
30373
30898
|
inputs: [],
|
|
@@ -30877,7 +31402,7 @@ var VanaPoolTreasuryABI = [
|
|
|
30877
31402
|
}
|
|
30878
31403
|
];
|
|
30879
31404
|
|
|
30880
|
-
// src/abi/DATImplementation.ts
|
|
31405
|
+
// src/generated/abi/DATImplementation.ts
|
|
30881
31406
|
var DATABI = [
|
|
30882
31407
|
{
|
|
30883
31408
|
inputs: [],
|
|
@@ -31783,7 +32308,7 @@ var DATABI = [
|
|
|
31783
32308
|
}
|
|
31784
32309
|
];
|
|
31785
32310
|
|
|
31786
|
-
// src/abi/DATFactoryImplementation.ts
|
|
32311
|
+
// src/generated/abi/DATFactoryImplementation.ts
|
|
31787
32312
|
var DATFactoryABI = [
|
|
31788
32313
|
{
|
|
31789
32314
|
inputs: [],
|
|
@@ -32637,7 +33162,7 @@ var DATFactoryABI = [
|
|
|
32637
33162
|
}
|
|
32638
33163
|
];
|
|
32639
33164
|
|
|
32640
|
-
// src/abi/DATPausableImplementation.ts
|
|
33165
|
+
// src/generated/abi/DATPausableImplementation.ts
|
|
32641
33166
|
var DATPausableABI = [
|
|
32642
33167
|
{
|
|
32643
33168
|
inputs: [],
|
|
@@ -34132,7 +34657,7 @@ var DATPausableABI = [
|
|
|
34132
34657
|
}
|
|
34133
34658
|
];
|
|
34134
34659
|
|
|
34135
|
-
// src/abi/DATVotesImplementation.ts
|
|
34660
|
+
// src/generated/abi/DATVotesImplementation.ts
|
|
34136
34661
|
var DATVotesABI = [
|
|
34137
34662
|
{
|
|
34138
34663
|
inputs: [],
|
|
@@ -35564,7 +36089,7 @@ var DATVotesABI = [
|
|
|
35564
36089
|
}
|
|
35565
36090
|
];
|
|
35566
36091
|
|
|
35567
|
-
// src/abi/index.ts
|
|
36092
|
+
// src/generated/abi/index.ts
|
|
35568
36093
|
var contractAbis = {
|
|
35569
36094
|
DataPortabilityPermissions: DataPortabilityPermissionsABI,
|
|
35570
36095
|
DataPortabilityServers: DataPortabilityServersABI,
|
|
@@ -35628,7 +36153,7 @@ async function parseTransactionResult(context, hash, operation) {
|
|
|
35628
36153
|
});
|
|
35629
36154
|
console.debug(`\u2705 Transaction confirmed in block ${receipt.blockNumber}`);
|
|
35630
36155
|
const abi = getAbi(mapping.contract);
|
|
35631
|
-
const events = (0,
|
|
36156
|
+
const events = (0, import_viem2.parseEventLogs)({
|
|
35632
36157
|
logs: receipt.logs,
|
|
35633
36158
|
abi,
|
|
35634
36159
|
eventName: mapping.event,
|
|
@@ -35670,292 +36195,103 @@ async function parseTransactionResult(context, hash, operation) {
|
|
|
35670
36195
|
}
|
|
35671
36196
|
}
|
|
35672
36197
|
|
|
35673
|
-
// src/
|
|
35674
|
-
var
|
|
35675
|
-
|
|
35676
|
-
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
1480: "0xD54523048AdD05b4d734aFaE7C68324Ebb7373eF"
|
|
35680
|
-
}
|
|
35681
|
-
},
|
|
35682
|
-
DataPortabilityServers: {
|
|
35683
|
-
addresses: {
|
|
35684
|
-
14800: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c",
|
|
35685
|
-
1480: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c"
|
|
35686
|
-
}
|
|
35687
|
-
},
|
|
35688
|
-
DataPortabilityGrantees: {
|
|
35689
|
-
addresses: {
|
|
35690
|
-
14800: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234",
|
|
35691
|
-
1480: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234"
|
|
35692
|
-
}
|
|
35693
|
-
},
|
|
35694
|
-
DataRegistry: {
|
|
35695
|
-
addresses: {
|
|
35696
|
-
14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
|
|
35697
|
-
1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
|
|
35698
|
-
}
|
|
35699
|
-
},
|
|
35700
|
-
TeePoolPhala: {
|
|
35701
|
-
addresses: {
|
|
35702
|
-
14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
|
|
35703
|
-
1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
|
|
35704
|
-
}
|
|
35705
|
-
},
|
|
35706
|
-
ComputeEngine: {
|
|
35707
|
-
addresses: {
|
|
35708
|
-
14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
|
|
35709
|
-
1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
|
|
35710
|
-
}
|
|
35711
|
-
},
|
|
35712
|
-
// Data Access Infrastructure
|
|
35713
|
-
DataRefinerRegistry: {
|
|
35714
|
-
addresses: {
|
|
35715
|
-
14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
|
|
35716
|
-
1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
|
|
35717
|
-
}
|
|
35718
|
-
},
|
|
35719
|
-
QueryEngine: {
|
|
35720
|
-
addresses: {
|
|
35721
|
-
14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
|
|
35722
|
-
1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
|
|
35723
|
-
}
|
|
35724
|
-
},
|
|
35725
|
-
VanaTreasury: {
|
|
35726
|
-
addresses: {
|
|
35727
|
-
14800: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD",
|
|
35728
|
-
1480: "0x94a1E56e555ac48d092f490fB10CDFaB434915eD"
|
|
35729
|
-
}
|
|
35730
|
-
},
|
|
35731
|
-
ComputeInstructionRegistry: {
|
|
35732
|
-
addresses: {
|
|
35733
|
-
14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
|
|
35734
|
-
1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
|
|
35735
|
-
}
|
|
35736
|
-
},
|
|
35737
|
-
// TEE Pool Variants
|
|
35738
|
-
TeePoolEphemeralStandard: {
|
|
35739
|
-
addresses: {
|
|
35740
|
-
14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
|
|
35741
|
-
1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
|
|
35742
|
-
}
|
|
35743
|
-
},
|
|
35744
|
-
TeePoolPersistentStandard: {
|
|
35745
|
-
addresses: {
|
|
35746
|
-
14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
|
|
35747
|
-
1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
|
|
35748
|
-
}
|
|
35749
|
-
},
|
|
35750
|
-
TeePoolPersistentGpu: {
|
|
35751
|
-
addresses: {
|
|
35752
|
-
14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
|
|
35753
|
-
1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
|
|
35754
|
-
}
|
|
35755
|
-
},
|
|
35756
|
-
TeePoolDedicatedStandard: {
|
|
35757
|
-
addresses: {
|
|
35758
|
-
14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
|
|
35759
|
-
1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
|
|
35760
|
-
}
|
|
35761
|
-
},
|
|
35762
|
-
TeePoolDedicatedGpu: {
|
|
35763
|
-
addresses: {
|
|
35764
|
-
14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
|
|
35765
|
-
1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
|
|
35766
|
-
}
|
|
35767
|
-
},
|
|
35768
|
-
// DLP Reward System
|
|
35769
|
-
VanaEpoch: {
|
|
35770
|
-
addresses: {
|
|
35771
|
-
14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
|
|
35772
|
-
1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
|
|
35773
|
-
}
|
|
35774
|
-
},
|
|
35775
|
-
DLPRegistry: {
|
|
35776
|
-
addresses: {
|
|
35777
|
-
14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
|
|
35778
|
-
1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
|
|
35779
|
-
}
|
|
35780
|
-
},
|
|
35781
|
-
DLPRegistryTreasury: {
|
|
35782
|
-
addresses: {
|
|
35783
|
-
14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
|
|
35784
|
-
1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
|
|
35785
|
-
}
|
|
35786
|
-
},
|
|
35787
|
-
DLPPerformance: {
|
|
35788
|
-
addresses: {
|
|
35789
|
-
14800: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1",
|
|
35790
|
-
1480: "0x847715C7DB37cF286611182Be0bD333cbfa29cc1"
|
|
35791
|
-
}
|
|
35792
|
-
},
|
|
35793
|
-
DLPRewardDeployer: {
|
|
35794
|
-
addresses: {
|
|
35795
|
-
14800: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04",
|
|
35796
|
-
1480: "0xEFD0F9Ba9De70586b7c4189971cF754adC923B04"
|
|
35797
|
-
}
|
|
35798
|
-
},
|
|
35799
|
-
DLPRewardDeployerTreasury: {
|
|
35800
|
-
addresses: {
|
|
35801
|
-
14800: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8",
|
|
35802
|
-
1480: "0xb547ca8Fe4990fe330FeAeb1C2EBb42F925Af5b8"
|
|
35803
|
-
}
|
|
35804
|
-
},
|
|
35805
|
-
DLPRewardSwap: {
|
|
35806
|
-
addresses: {
|
|
35807
|
-
14800: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0",
|
|
35808
|
-
1480: "0x7c6862C46830F0fc3bF3FF509EA1bD0EE7267fB0"
|
|
35809
|
-
}
|
|
35810
|
-
},
|
|
35811
|
-
SwapHelper: {
|
|
35812
|
-
addresses: {
|
|
35813
|
-
14800: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2",
|
|
35814
|
-
1480: "0x55D5e6F73326315bF2E091e97F04f0770e5C54e2"
|
|
35815
|
-
}
|
|
35816
|
-
},
|
|
35817
|
-
// VanaPool (Staking)
|
|
35818
|
-
VanaPoolStaking: {
|
|
35819
|
-
addresses: {
|
|
35820
|
-
14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
|
|
35821
|
-
1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
|
|
35822
|
-
}
|
|
35823
|
-
},
|
|
35824
|
-
VanaPoolEntity: {
|
|
35825
|
-
addresses: {
|
|
35826
|
-
14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
|
|
35827
|
-
1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
|
|
35828
|
-
}
|
|
35829
|
-
},
|
|
35830
|
-
VanaPoolTreasury: {
|
|
35831
|
-
addresses: {
|
|
35832
|
-
14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
|
|
35833
|
-
1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
|
|
35834
|
-
}
|
|
35835
|
-
},
|
|
35836
|
-
// DLP Deployment Contracts
|
|
35837
|
-
DAT: {
|
|
35838
|
-
addresses: {
|
|
35839
|
-
14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
|
|
35840
|
-
1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
|
|
35841
|
-
}
|
|
35842
|
-
},
|
|
35843
|
-
DATFactory: {
|
|
35844
|
-
addresses: {
|
|
35845
|
-
14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
|
|
35846
|
-
1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
|
|
35847
|
-
}
|
|
35848
|
-
},
|
|
35849
|
-
DATPausable: {
|
|
35850
|
-
addresses: {
|
|
35851
|
-
14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
|
|
35852
|
-
1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
|
|
35853
|
-
}
|
|
35854
|
-
},
|
|
35855
|
-
DATVotes: {
|
|
35856
|
-
addresses: {
|
|
35857
|
-
14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
|
|
35858
|
-
1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
|
|
35859
|
-
}
|
|
35860
|
-
},
|
|
35861
|
-
// Utility Contracts (no ABIs in SDK)
|
|
35862
|
-
Multicall3: {
|
|
35863
|
-
addresses: {
|
|
35864
|
-
14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
|
|
35865
|
-
1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
|
|
35866
|
-
}
|
|
35867
|
-
},
|
|
35868
|
-
Multisend: {
|
|
35869
|
-
addresses: {
|
|
35870
|
-
14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
|
|
35871
|
-
1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
|
|
35872
|
-
}
|
|
36198
|
+
// src/utils/transactionHandle.ts
|
|
36199
|
+
var TransactionHandle = class {
|
|
36200
|
+
constructor(context, hash, operation) {
|
|
36201
|
+
this.context = context;
|
|
36202
|
+
this.hash = hash;
|
|
36203
|
+
this.operation = operation;
|
|
35873
36204
|
}
|
|
35874
|
-
|
|
35875
|
-
|
|
35876
|
-
|
|
35877
|
-
|
|
35878
|
-
|
|
35879
|
-
|
|
35880
|
-
|
|
35881
|
-
|
|
35882
|
-
|
|
35883
|
-
|
|
35884
|
-
|
|
35885
|
-
|
|
35886
|
-
|
|
35887
|
-
|
|
35888
|
-
|
|
35889
|
-
|
|
35890
|
-
|
|
35891
|
-
|
|
35892
|
-
|
|
35893
|
-
|
|
35894
|
-
|
|
35895
|
-
|
|
35896
|
-
|
|
35897
|
-
|
|
35898
|
-
14800: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5",
|
|
35899
|
-
1480: "0xff14346dF2B8Fd0c95BF34f1c92e49417b508AD5"
|
|
35900
|
-
}
|
|
35901
|
-
},
|
|
35902
|
-
DLPRootMetrics: {
|
|
35903
|
-
addresses: {
|
|
35904
|
-
14800: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662",
|
|
35905
|
-
1480: "0xbb532917B6407c060Afd9Cb7d53527eCb91d6662"
|
|
36205
|
+
_receipt;
|
|
36206
|
+
_eventData;
|
|
36207
|
+
_receiptPromise;
|
|
36208
|
+
_eventPromise;
|
|
36209
|
+
/**
|
|
36210
|
+
* Waits for transaction confirmation and returns the receipt.
|
|
36211
|
+
* Results are memoized - multiple calls return the same promise.
|
|
36212
|
+
*
|
|
36213
|
+
* @param options Optional timeout configuration
|
|
36214
|
+
* @param options.timeout Timeout in milliseconds (default: 30000)
|
|
36215
|
+
* @returns Transaction receipt with gas usage, logs, and status
|
|
36216
|
+
*/
|
|
36217
|
+
async waitForReceipt(options) {
|
|
36218
|
+
if (this._receipt) {
|
|
36219
|
+
return this._receipt;
|
|
36220
|
+
}
|
|
36221
|
+
if (!this._receiptPromise) {
|
|
36222
|
+
this._receiptPromise = this.context.publicClient.waitForTransactionReceipt({
|
|
36223
|
+
hash: this.hash,
|
|
36224
|
+
timeout: options?.timeout ?? 3e4
|
|
36225
|
+
}).then((receipt) => {
|
|
36226
|
+
this._receipt = receipt;
|
|
36227
|
+
return receipt;
|
|
36228
|
+
});
|
|
35906
36229
|
}
|
|
35907
|
-
|
|
35908
|
-
|
|
35909
|
-
|
|
35910
|
-
|
|
35911
|
-
|
|
36230
|
+
return this._receiptPromise;
|
|
36231
|
+
}
|
|
36232
|
+
/**
|
|
36233
|
+
* Waits for transaction confirmation and parses emitted events.
|
|
36234
|
+
* Results are memoized - multiple calls return the same promise.
|
|
36235
|
+
*
|
|
36236
|
+
* @returns Parsed event data with transaction metadata
|
|
36237
|
+
* @throws {Error} If no operation was specified for event parsing
|
|
36238
|
+
*/
|
|
36239
|
+
async waitForEvents() {
|
|
36240
|
+
if (this._eventData) {
|
|
36241
|
+
return this._eventData;
|
|
35912
36242
|
}
|
|
35913
|
-
|
|
35914
|
-
|
|
35915
|
-
|
|
35916
|
-
|
|
35917
|
-
|
|
36243
|
+
if (!this._eventPromise) {
|
|
36244
|
+
if (!this.operation) {
|
|
36245
|
+
throw new Error(
|
|
36246
|
+
"Cannot parse events: no operation specified. Use waitForReceipt() instead or ensure the operation is configured."
|
|
36247
|
+
);
|
|
36248
|
+
}
|
|
36249
|
+
this._eventPromise = parseTransactionResult(
|
|
36250
|
+
this.context,
|
|
36251
|
+
this.hash,
|
|
36252
|
+
this.operation
|
|
36253
|
+
).then((eventData) => {
|
|
36254
|
+
this._eventData = eventData;
|
|
36255
|
+
return eventData;
|
|
36256
|
+
});
|
|
35918
36257
|
}
|
|
36258
|
+
return this._eventPromise;
|
|
35919
36259
|
}
|
|
35920
|
-
|
|
35921
|
-
|
|
35922
|
-
|
|
35923
|
-
|
|
35924
|
-
|
|
35925
|
-
|
|
35926
|
-
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
|
|
35930
|
-
|
|
35931
|
-
|
|
35932
|
-
|
|
35933
|
-
},
|
|
35934
|
-
1480: {
|
|
35935
|
-
Multicall3: CONTRACTS.Multicall3.addresses[1480],
|
|
35936
|
-
Multisend: CONTRACTS.Multisend.addresses[1480]
|
|
36260
|
+
/**
|
|
36261
|
+
* Enables string coercion for backwards compatibility.
|
|
36262
|
+
* Allows TransactionHandle to be used anywhere a Hash is expected.
|
|
36263
|
+
*
|
|
36264
|
+
* @example
|
|
36265
|
+
* ```typescript
|
|
36266
|
+
* const hash: Hash = tx; // Works via toString()
|
|
36267
|
+
* console.log(`Transaction: ${tx}`); // Prints hash
|
|
36268
|
+
* ```
|
|
36269
|
+
* @returns The transaction hash as a string
|
|
36270
|
+
*/
|
|
36271
|
+
toString() {
|
|
36272
|
+
return this.hash;
|
|
35937
36273
|
}
|
|
35938
|
-
|
|
35939
|
-
|
|
35940
|
-
|
|
35941
|
-
|
|
35942
|
-
|
|
35943
|
-
|
|
35944
|
-
|
|
35945
|
-
|
|
35946
|
-
}
|
|
35947
|
-
|
|
35948
|
-
|
|
35949
|
-
|
|
35950
|
-
|
|
35951
|
-
|
|
35952
|
-
|
|
36274
|
+
/**
|
|
36275
|
+
* JSON serialization support.
|
|
36276
|
+
* Returns the hash when serialized to JSON.
|
|
36277
|
+
*
|
|
36278
|
+
* @returns The transaction hash for JSON serialization
|
|
36279
|
+
*/
|
|
36280
|
+
toJSON() {
|
|
36281
|
+
return this.hash;
|
|
36282
|
+
}
|
|
36283
|
+
/**
|
|
36284
|
+
* Custom inspect for Node.js console.log
|
|
36285
|
+
*
|
|
36286
|
+
* @returns Formatted string representation for debugging
|
|
36287
|
+
*/
|
|
36288
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
36289
|
+
return `TransactionHandle { hash: '${this.hash}', operation: '${this.operation ?? "none"}' }`;
|
|
35953
36290
|
}
|
|
35954
|
-
return contractAddress;
|
|
35955
36291
|
};
|
|
35956
36292
|
|
|
35957
36293
|
// src/utils/grantFiles.ts
|
|
35958
|
-
var
|
|
36294
|
+
var import_viem3 = require("viem");
|
|
35959
36295
|
function createGrantFile(params) {
|
|
35960
36296
|
const grantFile = {
|
|
35961
36297
|
grantee: params.grantee,
|
|
@@ -36078,8 +36414,8 @@ function getGrantFileHash(grantFile) {
|
|
|
36078
36414
|
sortedFile.expires = grantFile.expires;
|
|
36079
36415
|
}
|
|
36080
36416
|
const jsonString = JSON.stringify(sortedFile);
|
|
36081
|
-
console.info(`Hash: ${(0,
|
|
36082
|
-
return (0,
|
|
36417
|
+
console.info(`Hash: ${(0, import_viem3.keccak256)((0, import_viem3.toHex)(jsonString))}`);
|
|
36418
|
+
return (0, import_viem3.keccak256)((0, import_viem3.toHex)(jsonString));
|
|
36083
36419
|
} catch (error) {
|
|
36084
36420
|
throw new SerializationError(
|
|
36085
36421
|
`Failed to generate grant file hash: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -36583,31 +36919,32 @@ var PermissionsController = class {
|
|
|
36583
36919
|
* ```
|
|
36584
36920
|
*/
|
|
36585
36921
|
async grant(params) {
|
|
36586
|
-
const
|
|
36587
|
-
return
|
|
36922
|
+
const txHandle = await this.submitPermissionGrant(params);
|
|
36923
|
+
return await txHandle.waitForEvents();
|
|
36588
36924
|
}
|
|
36589
36925
|
/**
|
|
36590
|
-
* Submits a permission grant transaction and returns
|
|
36926
|
+
* Submits a permission grant transaction and returns a handle for flexible result access.
|
|
36591
36927
|
*
|
|
36592
|
-
*
|
|
36593
|
-
*
|
|
36594
|
-
*
|
|
36928
|
+
* @remarks
|
|
36929
|
+
* This lower-level method provides maximum control over transaction timing.
|
|
36930
|
+
* Returns a TransactionHandle that allows immediate hash access or optional event parsing.
|
|
36931
|
+
* Use this when handling multiple transactions or when you need granular control.
|
|
36595
36932
|
*
|
|
36596
36933
|
* @param params - The permission grant configuration object
|
|
36597
|
-
* @returns Promise
|
|
36934
|
+
* @returns Promise resolving to TransactionHandle with hash and event parsing capabilities
|
|
36598
36935
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
36599
36936
|
* @throws {SignatureError} When user rejects the signature request
|
|
36600
36937
|
* @throws {SerializationError} When grant data cannot be serialized
|
|
36601
36938
|
* @throws {BlockchainError} When permission grant preparation fails
|
|
36602
36939
|
* @example
|
|
36603
36940
|
* ```typescript
|
|
36604
|
-
* // Submit transaction and
|
|
36605
|
-
* const
|
|
36606
|
-
* console.log(`Transaction submitted: ${
|
|
36941
|
+
* // Submit transaction and get immediate hash access
|
|
36942
|
+
* const tx = await vana.permissions.submitPermissionGrant(params);
|
|
36943
|
+
* console.log(`Transaction submitted: ${tx.hash}`);
|
|
36607
36944
|
*
|
|
36608
|
-
* //
|
|
36609
|
-
* const
|
|
36610
|
-
* console.log(`Permission ID: ${
|
|
36945
|
+
* // Optionally wait for and parse events
|
|
36946
|
+
* const eventData = await tx.waitForEvents();
|
|
36947
|
+
* console.log(`Permission ID: ${eventData.permissionId}`);
|
|
36611
36948
|
* ```
|
|
36612
36949
|
*/
|
|
36613
36950
|
async submitPermissionGrant(params) {
|
|
@@ -36665,12 +37002,18 @@ var PermissionsController = class {
|
|
|
36665
37002
|
}
|
|
36666
37003
|
}
|
|
36667
37004
|
/**
|
|
36668
|
-
*
|
|
36669
|
-
*
|
|
37005
|
+
* Completes the grant process after user confirmation.
|
|
37006
|
+
*
|
|
37007
|
+
* @remarks
|
|
37008
|
+
* This internal method is called by the confirm() function returned from prepareGrant().
|
|
37009
|
+
* It handles IPFS upload, signature creation, and transaction submission.
|
|
36670
37010
|
*
|
|
36671
37011
|
* @param params - The permission grant parameters containing user and operation details
|
|
36672
37012
|
* @param grantFile - The prepared grant file with permissions and metadata
|
|
36673
|
-
* @returns Promise resolving to
|
|
37013
|
+
* @returns Promise resolving to TransactionHandle for flexible result access
|
|
37014
|
+
* @throws {BlockchainError} When permission grant confirmation fails
|
|
37015
|
+
* @throws {NetworkError} When IPFS upload fails
|
|
37016
|
+
* @throws {SignatureError} When user rejects the signature
|
|
36674
37017
|
*/
|
|
36675
37018
|
async confirmGrantInternal(params, grantFile) {
|
|
36676
37019
|
try {
|
|
@@ -36859,14 +37202,20 @@ var PermissionsController = class {
|
|
|
36859
37202
|
2
|
|
36860
37203
|
)
|
|
36861
37204
|
);
|
|
37205
|
+
let hash;
|
|
36862
37206
|
if (this.context.relayerCallbacks?.submitPermissionGrant) {
|
|
36863
|
-
|
|
37207
|
+
hash = await this.context.relayerCallbacks.submitPermissionGrant(
|
|
36864
37208
|
typedData,
|
|
36865
37209
|
signature
|
|
36866
37210
|
);
|
|
36867
37211
|
} else {
|
|
36868
|
-
|
|
37212
|
+
hash = await this.submitDirectTransaction(typedData, signature);
|
|
36869
37213
|
}
|
|
37214
|
+
return new TransactionHandle(
|
|
37215
|
+
this.context,
|
|
37216
|
+
hash,
|
|
37217
|
+
"grant"
|
|
37218
|
+
);
|
|
36870
37219
|
} catch (error) {
|
|
36871
37220
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36872
37221
|
throw error;
|
|
@@ -36879,11 +37228,24 @@ var PermissionsController = class {
|
|
|
36879
37228
|
}
|
|
36880
37229
|
/**
|
|
36881
37230
|
* Submits an already-signed trust server transaction to the blockchain.
|
|
37231
|
+
*
|
|
37232
|
+
* @remarks
|
|
36882
37233
|
* This method extracts the trust server input from typed data and submits it directly.
|
|
37234
|
+
* Used internally by trust server methods after signature collection.
|
|
36883
37235
|
*
|
|
36884
37236
|
* @param typedData - The EIP-712 typed data for TrustServer
|
|
36885
|
-
* @param signature - The user's signature
|
|
36886
|
-
* @returns Promise resolving to
|
|
37237
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
37238
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37239
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37240
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
37241
|
+
* @example
|
|
37242
|
+
* ```typescript
|
|
37243
|
+
* const txHandle = await vana.permissions.submitSignedTrustServer(
|
|
37244
|
+
* typedData,
|
|
37245
|
+
* "0x1234..."
|
|
37246
|
+
* );
|
|
37247
|
+
* const result = await txHandle.waitForEvents();
|
|
37248
|
+
* ```
|
|
36887
37249
|
*/
|
|
36888
37250
|
async submitSignedTrustServer(typedData, signature) {
|
|
36889
37251
|
try {
|
|
@@ -36891,10 +37253,15 @@ var PermissionsController = class {
|
|
|
36891
37253
|
nonce: BigInt(typedData.message.nonce),
|
|
36892
37254
|
serverId: typedData.message.serverId
|
|
36893
37255
|
};
|
|
36894
|
-
|
|
37256
|
+
const hash = await this.submitTrustServerTransaction(
|
|
36895
37257
|
trustServerInput,
|
|
36896
37258
|
signature
|
|
36897
37259
|
);
|
|
37260
|
+
return new TransactionHandle(
|
|
37261
|
+
this.context,
|
|
37262
|
+
hash,
|
|
37263
|
+
"trustServer"
|
|
37264
|
+
);
|
|
36898
37265
|
} catch (error) {
|
|
36899
37266
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36900
37267
|
throw error;
|
|
@@ -36921,11 +37288,24 @@ var PermissionsController = class {
|
|
|
36921
37288
|
}
|
|
36922
37289
|
/**
|
|
36923
37290
|
* Submits an already-signed add and trust server transaction to the blockchain.
|
|
37291
|
+
*
|
|
37292
|
+
* @remarks
|
|
36924
37293
|
* This method extracts the add and trust server input from typed data and submits it directly.
|
|
37294
|
+
* Combines server registration and trust operations in a single transaction.
|
|
36925
37295
|
*
|
|
36926
37296
|
* @param typedData - The EIP-712 typed data for AddAndTrustServer
|
|
36927
|
-
* @param signature - The user's signature
|
|
36928
|
-
* @returns Promise resolving to
|
|
37297
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
37298
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37299
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37300
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
37301
|
+
* @example
|
|
37302
|
+
* ```typescript
|
|
37303
|
+
* const txHandle = await vana.permissions.submitSignedAddAndTrustServer(
|
|
37304
|
+
* typedData,
|
|
37305
|
+
* "0x1234..."
|
|
37306
|
+
* );
|
|
37307
|
+
* const result = await txHandle.waitForEvents();
|
|
37308
|
+
* ```
|
|
36929
37309
|
*/
|
|
36930
37310
|
async submitSignedAddAndTrustServer(typedData, signature) {
|
|
36931
37311
|
try {
|
|
@@ -36935,10 +37315,15 @@ var PermissionsController = class {
|
|
|
36935
37315
|
serverUrl: typedData.message.serverUrl,
|
|
36936
37316
|
publicKey: typedData.message.publicKey
|
|
36937
37317
|
};
|
|
36938
|
-
|
|
37318
|
+
const hash = await this.submitAddAndTrustServerTransaction(
|
|
36939
37319
|
addAndTrustServerInput,
|
|
36940
37320
|
signature
|
|
36941
37321
|
);
|
|
37322
|
+
return new TransactionHandle(
|
|
37323
|
+
this.context,
|
|
37324
|
+
hash,
|
|
37325
|
+
"addAndTrustServer"
|
|
37326
|
+
);
|
|
36942
37327
|
} catch (error) {
|
|
36943
37328
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36944
37329
|
throw error;
|
|
@@ -36951,22 +37336,41 @@ var PermissionsController = class {
|
|
|
36951
37336
|
}
|
|
36952
37337
|
/**
|
|
36953
37338
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
37339
|
+
*
|
|
37340
|
+
* @remarks
|
|
36954
37341
|
* This method handles the revocation of previously granted permissions.
|
|
37342
|
+
* Used internally by revocation methods after signature collection.
|
|
36955
37343
|
*
|
|
36956
37344
|
* @param typedData - The EIP-712 typed data for PermissionRevoke
|
|
36957
|
-
* @param signature - The user's signature
|
|
36958
|
-
* @returns Promise resolving to
|
|
37345
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
37346
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37347
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37348
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
37349
|
+
* @example
|
|
37350
|
+
* ```typescript
|
|
37351
|
+
* const txHandle = await vana.permissions.submitSignedRevoke(
|
|
37352
|
+
* typedData,
|
|
37353
|
+
* "0x1234..."
|
|
37354
|
+
* );
|
|
37355
|
+
* const result = await txHandle.waitForEvents();
|
|
37356
|
+
* ```
|
|
36959
37357
|
*/
|
|
36960
37358
|
async submitSignedRevoke(typedData, signature) {
|
|
36961
37359
|
try {
|
|
37360
|
+
let hash;
|
|
36962
37361
|
if (this.context.relayerCallbacks?.submitPermissionRevoke) {
|
|
36963
|
-
|
|
37362
|
+
hash = await this.context.relayerCallbacks.submitPermissionRevoke(
|
|
36964
37363
|
typedData,
|
|
36965
37364
|
signature
|
|
36966
37365
|
);
|
|
36967
37366
|
} else {
|
|
36968
|
-
|
|
37367
|
+
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
36969
37368
|
}
|
|
37369
|
+
return new TransactionHandle(
|
|
37370
|
+
this.context,
|
|
37371
|
+
hash,
|
|
37372
|
+
"revoke"
|
|
37373
|
+
);
|
|
36970
37374
|
} catch (error) {
|
|
36971
37375
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
36972
37376
|
throw error;
|
|
@@ -36979,22 +37383,41 @@ var PermissionsController = class {
|
|
|
36979
37383
|
}
|
|
36980
37384
|
/**
|
|
36981
37385
|
* Submits an already-signed untrust server transaction to the blockchain.
|
|
37386
|
+
*
|
|
37387
|
+
* @remarks
|
|
36982
37388
|
* This method handles the removal of trusted servers.
|
|
37389
|
+
* Used internally by untrust server methods after signature collection.
|
|
36983
37390
|
*
|
|
36984
37391
|
* @param typedData - The EIP-712 typed data for UntrustServer
|
|
36985
|
-
* @param signature - The user's signature
|
|
36986
|
-
* @returns Promise resolving to
|
|
37392
|
+
* @param signature - The user's signature obtained via `signTypedData()`
|
|
37393
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37394
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37395
|
+
* @throws {NetworkError} When blockchain communication fails
|
|
37396
|
+
* @example
|
|
37397
|
+
* ```typescript
|
|
37398
|
+
* const txHandle = await vana.permissions.submitSignedUntrustServer(
|
|
37399
|
+
* typedData,
|
|
37400
|
+
* "0x1234..."
|
|
37401
|
+
* );
|
|
37402
|
+
* const result = await txHandle.waitForEvents();
|
|
37403
|
+
* ```
|
|
36987
37404
|
*/
|
|
36988
37405
|
async submitSignedUntrustServer(typedData, signature) {
|
|
36989
37406
|
try {
|
|
37407
|
+
let hash;
|
|
36990
37408
|
if (this.context.relayerCallbacks?.submitUntrustServer) {
|
|
36991
|
-
|
|
37409
|
+
hash = await this.context.relayerCallbacks.submitUntrustServer(
|
|
36992
37410
|
typedData,
|
|
36993
37411
|
signature
|
|
36994
37412
|
);
|
|
36995
37413
|
} else {
|
|
36996
|
-
|
|
37414
|
+
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
36997
37415
|
}
|
|
37416
|
+
return new TransactionHandle(
|
|
37417
|
+
this.context,
|
|
37418
|
+
hash,
|
|
37419
|
+
"untrustServer"
|
|
37420
|
+
);
|
|
36998
37421
|
} catch (error) {
|
|
36999
37422
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
37000
37423
|
throw error;
|
|
@@ -37008,9 +37431,14 @@ var PermissionsController = class {
|
|
|
37008
37431
|
/**
|
|
37009
37432
|
* Submits a signed transaction directly to the blockchain.
|
|
37010
37433
|
*
|
|
37434
|
+
* @remarks
|
|
37435
|
+
* Internal method used when relayer callbacks are not available. Formats the signature
|
|
37436
|
+
* and submits the permission grant directly to the smart contract.
|
|
37437
|
+
*
|
|
37011
37438
|
* @param typedData - The typed data structure for the permission grant
|
|
37012
37439
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
37013
37440
|
* @returns Promise resolving to the transaction hash
|
|
37441
|
+
* @throws {BlockchainError} When contract submission fails
|
|
37014
37442
|
*/
|
|
37015
37443
|
async submitDirectTransaction(typedData, signature) {
|
|
37016
37444
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -37071,8 +37499,8 @@ var PermissionsController = class {
|
|
|
37071
37499
|
* ```
|
|
37072
37500
|
*/
|
|
37073
37501
|
async revoke(params) {
|
|
37074
|
-
const
|
|
37075
|
-
return
|
|
37502
|
+
const txHandle = await this.submitPermissionRevoke(params);
|
|
37503
|
+
return await txHandle.waitForEvents();
|
|
37076
37504
|
}
|
|
37077
37505
|
/**
|
|
37078
37506
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
@@ -37114,7 +37542,11 @@ var PermissionsController = class {
|
|
|
37114
37542
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37115
37543
|
chain: this.context.walletClient.chain || null
|
|
37116
37544
|
});
|
|
37117
|
-
return
|
|
37545
|
+
return new TransactionHandle(
|
|
37546
|
+
this.context,
|
|
37547
|
+
txHash,
|
|
37548
|
+
"revoke"
|
|
37549
|
+
);
|
|
37118
37550
|
} catch (error) {
|
|
37119
37551
|
if (error instanceof Error) {
|
|
37120
37552
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37129,15 +37561,29 @@ var PermissionsController = class {
|
|
|
37129
37561
|
}
|
|
37130
37562
|
}
|
|
37131
37563
|
/**
|
|
37132
|
-
* Revokes a permission with a signature
|
|
37564
|
+
* Revokes a permission with a signature for gasless transactions.
|
|
37565
|
+
*
|
|
37566
|
+
* @remarks
|
|
37567
|
+
* This method creates an EIP-712 signature for permission revocation and submits
|
|
37568
|
+
* it either through relayer callbacks or directly to the blockchain. Provides
|
|
37569
|
+
* gasless revocation when relayer is configured.
|
|
37133
37570
|
*
|
|
37134
37571
|
* @param params - Parameters for revoking the permission
|
|
37135
|
-
* @
|
|
37572
|
+
* @param params.permissionId - Permission identifier to revoke (accepts bigint, number, or string)
|
|
37573
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
37136
37574
|
* @throws {BlockchainError} When chain ID is not available
|
|
37137
37575
|
* @throws {NonceError} When retrieving user nonce fails
|
|
37138
37576
|
* @throws {SignatureError} When user rejects the signature request
|
|
37139
37577
|
* @throws {RelayerError} When gasless submission fails
|
|
37140
37578
|
* @throws {PermissionError} When revocation fails for any other reason
|
|
37579
|
+
* @example
|
|
37580
|
+
* ```typescript
|
|
37581
|
+
* const txHandle = await vana.permissions.submitRevokeWithSignature({
|
|
37582
|
+
* permissionId: 123n
|
|
37583
|
+
* });
|
|
37584
|
+
* const result = await txHandle.waitForEvents();
|
|
37585
|
+
* console.log(`Permission ${result.permissionId} revoked`);
|
|
37586
|
+
* ```
|
|
37141
37587
|
*/
|
|
37142
37588
|
async submitRevokeWithSignature(params) {
|
|
37143
37589
|
try {
|
|
@@ -37161,14 +37607,20 @@ var PermissionsController = class {
|
|
|
37161
37607
|
message: revokePermissionInput
|
|
37162
37608
|
};
|
|
37163
37609
|
const signature = await this.signTypedData(typedData);
|
|
37610
|
+
let hash;
|
|
37164
37611
|
if (this.context.relayerCallbacks?.submitPermissionRevoke) {
|
|
37165
|
-
|
|
37612
|
+
hash = await this.context.relayerCallbacks.submitPermissionRevoke(
|
|
37166
37613
|
typedData,
|
|
37167
37614
|
signature
|
|
37168
37615
|
);
|
|
37169
37616
|
} else {
|
|
37170
|
-
|
|
37617
|
+
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
37171
37618
|
}
|
|
37619
|
+
return new TransactionHandle(
|
|
37620
|
+
this.context,
|
|
37621
|
+
hash,
|
|
37622
|
+
"revoke"
|
|
37623
|
+
);
|
|
37172
37624
|
} catch (error) {
|
|
37173
37625
|
throw new PermissionError(
|
|
37174
37626
|
`Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -37200,6 +37652,18 @@ var PermissionsController = class {
|
|
|
37200
37652
|
* const serversNonce = await this.getServersUserNonce();
|
|
37201
37653
|
* ```
|
|
37202
37654
|
*/
|
|
37655
|
+
/**
|
|
37656
|
+
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
37657
|
+
*
|
|
37658
|
+
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
37659
|
+
*
|
|
37660
|
+
* @remarks
|
|
37661
|
+
* This method is deprecated in favor of more specific nonce methods that target
|
|
37662
|
+
* the appropriate contract for the operation being performed.
|
|
37663
|
+
*
|
|
37664
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37665
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37666
|
+
*/
|
|
37203
37667
|
async getUserNonce() {
|
|
37204
37668
|
try {
|
|
37205
37669
|
const userAddress = await this.getUserAddress();
|
|
@@ -37236,6 +37700,16 @@ var PermissionsController = class {
|
|
|
37236
37700
|
* console.log(`Current servers nonce: ${nonce}`);
|
|
37237
37701
|
* ```
|
|
37238
37702
|
*/
|
|
37703
|
+
/**
|
|
37704
|
+
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
37705
|
+
*
|
|
37706
|
+
* @remarks
|
|
37707
|
+
* Used for server-related operations (trust/untrust) to prevent replay attacks.
|
|
37708
|
+
* The nonce must be incremented with each server operation.
|
|
37709
|
+
*
|
|
37710
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37711
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37712
|
+
*/
|
|
37239
37713
|
async getServersUserNonce() {
|
|
37240
37714
|
try {
|
|
37241
37715
|
const userAddress = await this.getUserAddress();
|
|
@@ -37272,6 +37746,16 @@ var PermissionsController = class {
|
|
|
37272
37746
|
* console.log(`Current permissions nonce: ${nonce}`);
|
|
37273
37747
|
* ```
|
|
37274
37748
|
*/
|
|
37749
|
+
/**
|
|
37750
|
+
* Retrieves the user's current nonce from the DataPortabilityPermissions contract.
|
|
37751
|
+
*
|
|
37752
|
+
* @remarks
|
|
37753
|
+
* Used for permission-related operations (grant/revoke) to prevent replay attacks.
|
|
37754
|
+
* The nonce must be incremented with each permission operation.
|
|
37755
|
+
*
|
|
37756
|
+
* @returns Promise resolving to the user's current nonce as a bigint
|
|
37757
|
+
* @throws {NonceError} When retrieving the nonce fails
|
|
37758
|
+
*/
|
|
37275
37759
|
async getPermissionsUserNonce() {
|
|
37276
37760
|
try {
|
|
37277
37761
|
const userAddress = await this.getUserAddress();
|
|
@@ -37677,7 +38161,11 @@ var PermissionsController = class {
|
|
|
37677
38161
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37678
38162
|
chain: this.context.walletClient.chain || null
|
|
37679
38163
|
});
|
|
37680
|
-
return
|
|
38164
|
+
return new TransactionHandle(
|
|
38165
|
+
this.context,
|
|
38166
|
+
txHash,
|
|
38167
|
+
"addAndTrustServer"
|
|
38168
|
+
);
|
|
37681
38169
|
} catch (error) {
|
|
37682
38170
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37683
38171
|
throw new UserRejectedRequestError();
|
|
@@ -37711,7 +38199,11 @@ var PermissionsController = class {
|
|
|
37711
38199
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37712
38200
|
chain: this.context.walletClient.chain || null
|
|
37713
38201
|
});
|
|
37714
|
-
return
|
|
38202
|
+
return new TransactionHandle(
|
|
38203
|
+
this.context,
|
|
38204
|
+
txHash,
|
|
38205
|
+
"trustServer"
|
|
38206
|
+
);
|
|
37715
38207
|
} catch (error) {
|
|
37716
38208
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37717
38209
|
throw new UserRejectedRequestError();
|
|
@@ -37726,7 +38218,7 @@ var PermissionsController = class {
|
|
|
37726
38218
|
* Adds and trusts a server using a signature (gasless transaction).
|
|
37727
38219
|
*
|
|
37728
38220
|
* @param params - Parameters for adding and trusting the server
|
|
37729
|
-
* @returns Promise resolving to
|
|
38221
|
+
* @returns Promise resolving to TransactionHandle with ServerTrustResult event data
|
|
37730
38222
|
*/
|
|
37731
38223
|
async submitAddAndTrustServerWithSignature(params) {
|
|
37732
38224
|
try {
|
|
@@ -37750,17 +38242,23 @@ var PermissionsController = class {
|
|
|
37750
38242
|
});
|
|
37751
38243
|
const signature = await this.signTypedData(typedData);
|
|
37752
38244
|
console.debug("\u{1F50D} Generated signature:", signature);
|
|
38245
|
+
let hash;
|
|
37753
38246
|
if (this.context.relayerCallbacks?.submitAddAndTrustServer) {
|
|
37754
|
-
|
|
38247
|
+
hash = await this.context.relayerCallbacks.submitAddAndTrustServer(
|
|
37755
38248
|
typedData,
|
|
37756
38249
|
signature
|
|
37757
38250
|
);
|
|
37758
38251
|
} else {
|
|
37759
|
-
|
|
38252
|
+
hash = await this.submitAddAndTrustServerTransaction(
|
|
37760
38253
|
addAndTrustServerInput,
|
|
37761
38254
|
signature
|
|
37762
38255
|
);
|
|
37763
38256
|
}
|
|
38257
|
+
return new TransactionHandle(
|
|
38258
|
+
this.context,
|
|
38259
|
+
hash,
|
|
38260
|
+
"addAndTrustServer"
|
|
38261
|
+
);
|
|
37764
38262
|
} catch (error) {
|
|
37765
38263
|
if (error instanceof Error) {
|
|
37766
38264
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37798,17 +38296,23 @@ var PermissionsController = class {
|
|
|
37798
38296
|
};
|
|
37799
38297
|
const typedData = await this.composeTrustServerMessage(trustServerInput);
|
|
37800
38298
|
const signature = await this.signTypedData(typedData);
|
|
38299
|
+
let hash;
|
|
37801
38300
|
if (this.context.relayerCallbacks?.submitTrustServer) {
|
|
37802
|
-
|
|
38301
|
+
hash = await this.context.relayerCallbacks.submitTrustServer(
|
|
37803
38302
|
typedData,
|
|
37804
38303
|
signature
|
|
37805
38304
|
);
|
|
37806
38305
|
} else {
|
|
37807
|
-
|
|
38306
|
+
hash = await this.submitTrustServerTransaction(
|
|
37808
38307
|
trustServerInput,
|
|
37809
38308
|
signature
|
|
37810
38309
|
);
|
|
37811
38310
|
}
|
|
38311
|
+
return new TransactionHandle(
|
|
38312
|
+
this.context,
|
|
38313
|
+
hash,
|
|
38314
|
+
"trustServer"
|
|
38315
|
+
);
|
|
37812
38316
|
} catch (error) {
|
|
37813
38317
|
if (error instanceof Error) {
|
|
37814
38318
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -37828,6 +38332,17 @@ var PermissionsController = class {
|
|
|
37828
38332
|
* @param params - The untrust server parameters containing server details
|
|
37829
38333
|
* @returns Promise resolving to the transaction hash
|
|
37830
38334
|
*/
|
|
38335
|
+
/**
|
|
38336
|
+
* Submits an untrust server transaction directly to the blockchain.
|
|
38337
|
+
*
|
|
38338
|
+
* @remarks
|
|
38339
|
+
* Internal method used for direct blockchain submission of untrust server operations
|
|
38340
|
+
* when relayer callbacks are not available.
|
|
38341
|
+
*
|
|
38342
|
+
* @param params - The untrust server parameters
|
|
38343
|
+
* @returns Promise resolving to TransactionHandle for transaction tracking
|
|
38344
|
+
* @throws {BlockchainError} When contract submission fails
|
|
38345
|
+
*/
|
|
37831
38346
|
async submitDirectUntrustTransaction(params) {
|
|
37832
38347
|
try {
|
|
37833
38348
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -37844,7 +38359,11 @@ var PermissionsController = class {
|
|
|
37844
38359
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
37845
38360
|
chain: this.context.walletClient.chain || null
|
|
37846
38361
|
});
|
|
37847
|
-
return
|
|
38362
|
+
return new TransactionHandle(
|
|
38363
|
+
this.context,
|
|
38364
|
+
txHash,
|
|
38365
|
+
"untrustServer"
|
|
38366
|
+
);
|
|
37848
38367
|
} catch (error) {
|
|
37849
38368
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
37850
38369
|
throw new UserRejectedRequestError();
|
|
@@ -37912,14 +38431,20 @@ var PermissionsController = class {
|
|
|
37912
38431
|
};
|
|
37913
38432
|
const typedData = await this.composeUntrustServerMessage(untrustServerInput);
|
|
37914
38433
|
const signature = await this.signTypedData(typedData);
|
|
38434
|
+
let hash;
|
|
37915
38435
|
if (this.context.relayerCallbacks?.submitUntrustServer) {
|
|
37916
|
-
|
|
38436
|
+
hash = await this.context.relayerCallbacks.submitUntrustServer(
|
|
37917
38437
|
typedData,
|
|
37918
38438
|
signature
|
|
37919
38439
|
);
|
|
37920
38440
|
} else {
|
|
37921
|
-
|
|
38441
|
+
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
37922
38442
|
}
|
|
38443
|
+
return new TransactionHandle(
|
|
38444
|
+
this.context,
|
|
38445
|
+
hash,
|
|
38446
|
+
"untrustServer"
|
|
38447
|
+
);
|
|
37923
38448
|
} catch (error) {
|
|
37924
38449
|
if (error instanceof Error) {
|
|
37925
38450
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -38043,18 +38568,19 @@ var PermissionsController = class {
|
|
|
38043
38568
|
};
|
|
38044
38569
|
}
|
|
38045
38570
|
const endIndex = Math.min(offset + limit, total);
|
|
38046
|
-
const
|
|
38571
|
+
const serverIdCalls = [];
|
|
38047
38572
|
for (let i = offset; i < endIndex; i++) {
|
|
38048
|
-
|
|
38573
|
+
serverIdCalls.push({
|
|
38049
38574
|
address: DataPortabilityServersAddress,
|
|
38050
38575
|
abi: DataPortabilityServersAbi,
|
|
38051
38576
|
functionName: "userServerIdsAt",
|
|
38052
38577
|
args: [user, BigInt(i)]
|
|
38053
38578
|
});
|
|
38054
|
-
serverPromises.push(promise);
|
|
38055
38579
|
}
|
|
38056
|
-
const
|
|
38057
|
-
|
|
38580
|
+
const serverIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38581
|
+
contracts: serverIdCalls
|
|
38582
|
+
});
|
|
38583
|
+
const servers = serverIdResults.map((result) => Number(result)).filter((id) => id > 0);
|
|
38058
38584
|
return {
|
|
38059
38585
|
servers,
|
|
38060
38586
|
total,
|
|
@@ -38079,35 +38605,51 @@ var PermissionsController = class {
|
|
|
38079
38605
|
async getTrustedServersWithInfo(options = {}) {
|
|
38080
38606
|
try {
|
|
38081
38607
|
const paginatedResult = await this.getTrustedServersPaginated(options);
|
|
38082
|
-
const
|
|
38083
|
-
|
|
38084
|
-
|
|
38085
|
-
|
|
38086
|
-
|
|
38087
|
-
|
|
38088
|
-
|
|
38089
|
-
|
|
38090
|
-
|
|
38091
|
-
|
|
38092
|
-
|
|
38093
|
-
|
|
38094
|
-
|
|
38095
|
-
// 0 means still active
|
|
38096
|
-
};
|
|
38097
|
-
} catch {
|
|
38098
|
-
return {
|
|
38099
|
-
id: BigInt(serverId),
|
|
38100
|
-
owner: "0x0000000000000000000000000000000000000000",
|
|
38101
|
-
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
38102
|
-
publicKey: "",
|
|
38103
|
-
url: "",
|
|
38104
|
-
startBlock: 0n,
|
|
38105
|
-
endBlock: 0n
|
|
38106
|
-
};
|
|
38107
|
-
}
|
|
38108
|
-
}
|
|
38608
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
38609
|
+
const DataPortabilityServersAddress = getContractAddress(
|
|
38610
|
+
chainId,
|
|
38611
|
+
"DataPortabilityServers"
|
|
38612
|
+
);
|
|
38613
|
+
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
38614
|
+
const serverInfoCalls = paginatedResult.servers.map(
|
|
38615
|
+
(serverId) => ({
|
|
38616
|
+
address: DataPortabilityServersAddress,
|
|
38617
|
+
abi: DataPortabilityServersAbi,
|
|
38618
|
+
functionName: "servers",
|
|
38619
|
+
args: [BigInt(serverId)]
|
|
38620
|
+
})
|
|
38109
38621
|
);
|
|
38110
|
-
|
|
38622
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38623
|
+
contracts: serverInfoCalls,
|
|
38624
|
+
allowFailure: true
|
|
38625
|
+
});
|
|
38626
|
+
return serverInfoResults.map((result, index) => {
|
|
38627
|
+
const serverId = paginatedResult.servers[index];
|
|
38628
|
+
if (result.status === "success" && result.result) {
|
|
38629
|
+
const serverInfo = result.result;
|
|
38630
|
+
return {
|
|
38631
|
+
id: BigInt(serverId),
|
|
38632
|
+
owner: serverInfo.owner,
|
|
38633
|
+
serverAddress: serverInfo.serverAddress,
|
|
38634
|
+
publicKey: serverInfo.publicKey,
|
|
38635
|
+
url: serverInfo.url,
|
|
38636
|
+
startBlock: 0n,
|
|
38637
|
+
// We don't have this info from the old method structure
|
|
38638
|
+
endBlock: 0n
|
|
38639
|
+
// 0 means still active
|
|
38640
|
+
};
|
|
38641
|
+
} else {
|
|
38642
|
+
return {
|
|
38643
|
+
id: BigInt(serverId),
|
|
38644
|
+
owner: "0x0000000000000000000000000000000000000000",
|
|
38645
|
+
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
38646
|
+
publicKey: "",
|
|
38647
|
+
url: "",
|
|
38648
|
+
startBlock: 0n,
|
|
38649
|
+
endBlock: 0n
|
|
38650
|
+
};
|
|
38651
|
+
}
|
|
38652
|
+
});
|
|
38111
38653
|
} catch (error) {
|
|
38112
38654
|
throw new BlockchainError(
|
|
38113
38655
|
`Failed to get trusted servers with info: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -38118,9 +38660,28 @@ var PermissionsController = class {
|
|
|
38118
38660
|
/**
|
|
38119
38661
|
* Gets server information for multiple servers efficiently.
|
|
38120
38662
|
*
|
|
38121
|
-
* @
|
|
38122
|
-
*
|
|
38663
|
+
* @remarks
|
|
38664
|
+
* This method uses multicall to fetch information for multiple servers in a single
|
|
38665
|
+
* blockchain call, improving performance when querying many servers. Failed lookups
|
|
38666
|
+
* are returned separately for error handling.
|
|
38667
|
+
*
|
|
38668
|
+
* @param serverIds - Array of numeric server IDs to query
|
|
38669
|
+
* @returns Promise resolving to batch result containing successful lookups and failed IDs
|
|
38123
38670
|
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
38671
|
+
* @example
|
|
38672
|
+
* ```typescript
|
|
38673
|
+
* const result = await vana.permissions.getServerInfoBatch([1, 2, 3, 999]);
|
|
38674
|
+
*
|
|
38675
|
+
* // Process successful lookups
|
|
38676
|
+
* result.servers.forEach((server, id) => {
|
|
38677
|
+
* console.log(`Server ${id}: ${server.url}`);
|
|
38678
|
+
* });
|
|
38679
|
+
*
|
|
38680
|
+
* // Handle failed lookups
|
|
38681
|
+
* if (result.failed.length > 0) {
|
|
38682
|
+
* console.log(`Failed to fetch: ${result.failed.join(', ')}`);
|
|
38683
|
+
* }
|
|
38684
|
+
* ```
|
|
38124
38685
|
*/
|
|
38125
38686
|
async getServerInfoBatch(serverIds) {
|
|
38126
38687
|
if (serverIds.length === 0) {
|
|
@@ -38136,14 +38697,22 @@ var PermissionsController = class {
|
|
|
38136
38697
|
"DataPortabilityServers"
|
|
38137
38698
|
);
|
|
38138
38699
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
38139
|
-
const
|
|
38140
|
-
|
|
38141
|
-
|
|
38142
|
-
|
|
38143
|
-
|
|
38144
|
-
|
|
38145
|
-
|
|
38146
|
-
|
|
38700
|
+
const serverInfoCalls = serverIds.map(
|
|
38701
|
+
(serverId) => ({
|
|
38702
|
+
address: DataPortabilityServersAddress,
|
|
38703
|
+
abi: DataPortabilityServersAbi,
|
|
38704
|
+
functionName: "servers",
|
|
38705
|
+
args: [BigInt(serverId)]
|
|
38706
|
+
})
|
|
38707
|
+
);
|
|
38708
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
38709
|
+
contracts: serverInfoCalls,
|
|
38710
|
+
allowFailure: true
|
|
38711
|
+
});
|
|
38712
|
+
const results = serverInfoResults.map((result, index) => {
|
|
38713
|
+
const serverId = serverIds[index];
|
|
38714
|
+
if (result.status === "success" && result.result) {
|
|
38715
|
+
const serverInfo = result.result;
|
|
38147
38716
|
const server = {
|
|
38148
38717
|
id: Number(serverInfo.id),
|
|
38149
38718
|
owner: serverInfo.owner,
|
|
@@ -38152,11 +38721,10 @@ var PermissionsController = class {
|
|
|
38152
38721
|
publicKey: serverInfo.publicKey
|
|
38153
38722
|
};
|
|
38154
38723
|
return { serverId, server, success: true };
|
|
38155
|
-
}
|
|
38724
|
+
} else {
|
|
38156
38725
|
return { serverId, server: null, success: false };
|
|
38157
38726
|
}
|
|
38158
38727
|
});
|
|
38159
|
-
const results = await Promise.all(serverInfoPromises);
|
|
38160
38728
|
const servers = /* @__PURE__ */ new Map();
|
|
38161
38729
|
const failed = [];
|
|
38162
38730
|
for (const result of results) {
|
|
@@ -38177,9 +38745,24 @@ var PermissionsController = class {
|
|
|
38177
38745
|
/**
|
|
38178
38746
|
* Checks whether a specific server is trusted by a user.
|
|
38179
38747
|
*
|
|
38180
|
-
* @
|
|
38748
|
+
* @remarks
|
|
38749
|
+
* This method queries the user's trusted server list and checks if the specified
|
|
38750
|
+
* server is present. Returns both the trust status and the index in the trust list
|
|
38751
|
+
* if trusted.
|
|
38752
|
+
*
|
|
38753
|
+
* @param serverId - Numeric server ID to check
|
|
38181
38754
|
* @param userAddress - Optional user address (defaults to current user)
|
|
38182
|
-
* @returns Promise resolving to server trust status
|
|
38755
|
+
* @returns Promise resolving to server trust status with trust index if applicable
|
|
38756
|
+
* @throws {BlockchainError} When reading from contract fails
|
|
38757
|
+
* @example
|
|
38758
|
+
* ```typescript
|
|
38759
|
+
* const status = await vana.permissions.checkServerTrustStatus(1);
|
|
38760
|
+
* if (status.isTrusted) {
|
|
38761
|
+
* console.log(`Server is trusted at index ${status.trustIndex}`);
|
|
38762
|
+
* } else {
|
|
38763
|
+
* console.log('Server is not trusted');
|
|
38764
|
+
* }
|
|
38765
|
+
* ```
|
|
38183
38766
|
*/
|
|
38184
38767
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
38185
38768
|
try {
|
|
@@ -38203,6 +38786,10 @@ var PermissionsController = class {
|
|
|
38203
38786
|
/**
|
|
38204
38787
|
* Composes EIP-712 typed data for AddAndTrustServer.
|
|
38205
38788
|
*
|
|
38789
|
+
* @remarks
|
|
38790
|
+
* Creates the complete typed data structure required for EIP-712 signature generation
|
|
38791
|
+
* when adding and trusting a new server in a single transaction.
|
|
38792
|
+
*
|
|
38206
38793
|
* @param input - The add and trust server input data containing server details
|
|
38207
38794
|
* @returns Promise resolving to the typed data structure for server add and trust
|
|
38208
38795
|
*/
|
|
@@ -38451,7 +39038,11 @@ var PermissionsController = class {
|
|
|
38451
39038
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
38452
39039
|
chain: this.context.walletClient.chain || null
|
|
38453
39040
|
});
|
|
38454
|
-
return
|
|
39041
|
+
return new TransactionHandle(
|
|
39042
|
+
this.context,
|
|
39043
|
+
txHash,
|
|
39044
|
+
"registerGrantee"
|
|
39045
|
+
);
|
|
38455
39046
|
}
|
|
38456
39047
|
/**
|
|
38457
39048
|
* Registers a grantee with a signature (gasless transaction)
|
|
@@ -38478,7 +39069,15 @@ var PermissionsController = class {
|
|
|
38478
39069
|
};
|
|
38479
39070
|
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
38480
39071
|
const signature = await this.signTypedData(typedData);
|
|
38481
|
-
|
|
39072
|
+
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
39073
|
+
typedData,
|
|
39074
|
+
signature
|
|
39075
|
+
);
|
|
39076
|
+
return new TransactionHandle(
|
|
39077
|
+
this.context,
|
|
39078
|
+
hash,
|
|
39079
|
+
"registerGrantee"
|
|
39080
|
+
);
|
|
38482
39081
|
}
|
|
38483
39082
|
/**
|
|
38484
39083
|
* Submits a signed register grantee transaction via relayer
|
|
@@ -38493,7 +39092,15 @@ var PermissionsController = class {
|
|
|
38493
39092
|
* ```
|
|
38494
39093
|
*/
|
|
38495
39094
|
async submitSignedRegisterGrantee(typedData, signature) {
|
|
38496
|
-
|
|
39095
|
+
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
39096
|
+
typedData,
|
|
39097
|
+
signature
|
|
39098
|
+
);
|
|
39099
|
+
return new TransactionHandle(
|
|
39100
|
+
this.context,
|
|
39101
|
+
hash,
|
|
39102
|
+
"registerGrantee"
|
|
39103
|
+
);
|
|
38497
39104
|
}
|
|
38498
39105
|
/**
|
|
38499
39106
|
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
@@ -39479,7 +40086,11 @@ var PermissionsController = class {
|
|
|
39479
40086
|
chain: this.context.walletClient.chain,
|
|
39480
40087
|
account: this.context.walletClient.account || null
|
|
39481
40088
|
});
|
|
39482
|
-
return
|
|
40089
|
+
return new TransactionHandle(
|
|
40090
|
+
this.context,
|
|
40091
|
+
hash,
|
|
40092
|
+
"updateServer"
|
|
40093
|
+
);
|
|
39483
40094
|
} catch (error) {
|
|
39484
40095
|
throw new BlockchainError(
|
|
39485
40096
|
`Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -39660,24 +40271,30 @@ var PermissionsController = class {
|
|
|
39660
40271
|
*
|
|
39661
40272
|
* @param typedData - The EIP-712 typed data for AddPermission
|
|
39662
40273
|
* @param signature - The user's signature
|
|
39663
|
-
* @returns Promise resolving to
|
|
40274
|
+
* @returns Promise resolving to TransactionHandle with PermissionGrantResult event data
|
|
39664
40275
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
39665
40276
|
* @throws {BlockchainError} When permission addition fails
|
|
39666
40277
|
* @throws {NetworkError} When network communication fails
|
|
39667
40278
|
*/
|
|
39668
40279
|
async submitSignedAddPermission(typedData, signature) {
|
|
39669
40280
|
try {
|
|
40281
|
+
let hash;
|
|
39670
40282
|
if (this.context.relayerCallbacks?.submitAddPermission) {
|
|
39671
|
-
|
|
40283
|
+
hash = await this.context.relayerCallbacks.submitAddPermission(
|
|
39672
40284
|
typedData,
|
|
39673
40285
|
signature
|
|
39674
40286
|
);
|
|
39675
40287
|
} else {
|
|
39676
|
-
|
|
40288
|
+
hash = await this.submitDirectAddPermissionTransaction(
|
|
39677
40289
|
typedData,
|
|
39678
40290
|
signature
|
|
39679
40291
|
);
|
|
39680
40292
|
}
|
|
40293
|
+
return new TransactionHandle(
|
|
40294
|
+
this.context,
|
|
40295
|
+
hash,
|
|
40296
|
+
"addServerFilesAndPermissions"
|
|
40297
|
+
);
|
|
39681
40298
|
} catch (error) {
|
|
39682
40299
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
39683
40300
|
throw error;
|
|
@@ -39731,14 +40348,31 @@ var PermissionsController = class {
|
|
|
39731
40348
|
}
|
|
39732
40349
|
/**
|
|
39733
40350
|
* Submits an already-signed add server files and permissions transaction to the blockchain.
|
|
39734
|
-
*
|
|
40351
|
+
*
|
|
40352
|
+
* @remarks
|
|
40353
|
+
* This method returns a TransactionHandle that provides immediate access to the transaction hash
|
|
40354
|
+
* while allowing lazy-loaded access to parsed event data. Use `waitForEvents()` to retrieve
|
|
40355
|
+
* the permission ID and other event details after transaction confirmation.
|
|
39735
40356
|
*
|
|
39736
40357
|
* @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
|
|
39737
40358
|
* @param signature - The user's signature
|
|
39738
|
-
* @returns
|
|
40359
|
+
* @returns TransactionHandle with immediate hash access and optional event parsing
|
|
39739
40360
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
39740
40361
|
* @throws {BlockchainError} When server files and permissions addition fails
|
|
39741
40362
|
* @throws {NetworkError} When network communication fails
|
|
40363
|
+
*
|
|
40364
|
+
* @example
|
|
40365
|
+
* ```typescript
|
|
40366
|
+
* const tx = await vana.permissions.submitSignedAddServerFilesAndPermissions(
|
|
40367
|
+
* typedData,
|
|
40368
|
+
* signature
|
|
40369
|
+
* );
|
|
40370
|
+
* console.log(`Transaction submitted: ${tx.hash}`);
|
|
40371
|
+
*
|
|
40372
|
+
* // Wait for confirmation and get the permission ID
|
|
40373
|
+
* const { permissionId } = await tx.waitForEvents();
|
|
40374
|
+
* console.log(`Permission created with ID: ${permissionId}`);
|
|
40375
|
+
* ```
|
|
39742
40376
|
*/
|
|
39743
40377
|
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
39744
40378
|
try {
|
|
@@ -39751,18 +40385,28 @@ var PermissionsController = class {
|
|
|
39751
40385
|
console.debug(
|
|
39752
40386
|
"\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
|
|
39753
40387
|
);
|
|
39754
|
-
|
|
40388
|
+
const hash = await this.context.relayerCallbacks.submitAddServerFilesAndPermissions(
|
|
39755
40389
|
typedData,
|
|
39756
40390
|
signature
|
|
39757
40391
|
);
|
|
40392
|
+
return new TransactionHandle(
|
|
40393
|
+
this.context,
|
|
40394
|
+
hash,
|
|
40395
|
+
"addServerFilesAndPermissions"
|
|
40396
|
+
);
|
|
39758
40397
|
} else {
|
|
39759
40398
|
console.debug(
|
|
39760
40399
|
"\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
|
|
39761
40400
|
);
|
|
39762
|
-
|
|
40401
|
+
const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
39763
40402
|
typedData,
|
|
39764
40403
|
signature
|
|
39765
40404
|
);
|
|
40405
|
+
return new TransactionHandle(
|
|
40406
|
+
this.context,
|
|
40407
|
+
hash,
|
|
40408
|
+
"addServerFilesAndPermissions"
|
|
40409
|
+
);
|
|
39766
40410
|
}
|
|
39767
40411
|
} catch (error) {
|
|
39768
40412
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
@@ -39798,7 +40442,11 @@ var PermissionsController = class {
|
|
|
39798
40442
|
chain: this.context.walletClient.chain,
|
|
39799
40443
|
account: this.context.walletClient.account || null
|
|
39800
40444
|
});
|
|
39801
|
-
return
|
|
40445
|
+
return new TransactionHandle(
|
|
40446
|
+
this.context,
|
|
40447
|
+
hash,
|
|
40448
|
+
"revokePermission"
|
|
40449
|
+
);
|
|
39802
40450
|
} catch (error) {
|
|
39803
40451
|
throw new BlockchainError(
|
|
39804
40452
|
`Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -39876,10 +40524,10 @@ var PermissionsController = class {
|
|
|
39876
40524
|
};
|
|
39877
40525
|
|
|
39878
40526
|
// src/controllers/data.ts
|
|
39879
|
-
var
|
|
40527
|
+
var import_viem5 = require("viem");
|
|
39880
40528
|
|
|
39881
40529
|
// src/utils/blockchain/registry.ts
|
|
39882
|
-
var
|
|
40530
|
+
var import_viem4 = require("viem");
|
|
39883
40531
|
async function fetchSchemaFromChain(context, schemaId) {
|
|
39884
40532
|
const chainId = context.walletClient.chain?.id;
|
|
39885
40533
|
if (!chainId) {
|
|
@@ -39890,7 +40538,7 @@ async function fetchSchemaFromChain(context, schemaId) {
|
|
|
39890
40538
|
"DataRefinerRegistry"
|
|
39891
40539
|
);
|
|
39892
40540
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
39893
|
-
const dataRefinerRegistry = (0,
|
|
40541
|
+
const dataRefinerRegistry = (0, import_viem4.getContract)({
|
|
39894
40542
|
address: dataRefinerRegistryAddress,
|
|
39895
40543
|
abi: dataRefinerRegistryAbi,
|
|
39896
40544
|
client: context.publicClient
|
|
@@ -39900,13 +40548,13 @@ async function fetchSchemaFromChain(context, schemaId) {
|
|
|
39900
40548
|
throw new Error(`Schema with ID ${schemaId} not found`);
|
|
39901
40549
|
}
|
|
39902
40550
|
const schemaObj = schemaData;
|
|
39903
|
-
if (!schemaObj.name || !schemaObj.
|
|
40551
|
+
if (!schemaObj.name || !schemaObj.dialect || !schemaObj.definitionUrl) {
|
|
39904
40552
|
throw new Error("Incomplete schema data");
|
|
39905
40553
|
}
|
|
39906
40554
|
return {
|
|
39907
40555
|
id: schemaId,
|
|
39908
40556
|
name: schemaObj.name,
|
|
39909
|
-
|
|
40557
|
+
dialect: schemaObj.dialect,
|
|
39910
40558
|
definitionUrl: schemaObj.definitionUrl
|
|
39911
40559
|
};
|
|
39912
40560
|
}
|
|
@@ -39920,7 +40568,7 @@ async function fetchSchemaCountFromChain(context) {
|
|
|
39920
40568
|
"DataRefinerRegistry"
|
|
39921
40569
|
);
|
|
39922
40570
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
39923
|
-
const dataRefinerRegistry = (0,
|
|
40571
|
+
const dataRefinerRegistry = (0, import_viem4.getContract)({
|
|
39924
40572
|
address: dataRefinerRegistryAddress,
|
|
39925
40573
|
abi: dataRefinerRegistryAbi,
|
|
39926
40574
|
client: context.publicClient
|
|
@@ -40353,8 +41001,8 @@ var DataController = class {
|
|
|
40353
41001
|
*/
|
|
40354
41002
|
async getUserFiles(params) {
|
|
40355
41003
|
const { owner, subgraphUrl } = params;
|
|
40356
|
-
const
|
|
40357
|
-
if (!
|
|
41004
|
+
const endpoint = subgraphUrl || this.context.subgraphUrl;
|
|
41005
|
+
if (!endpoint) {
|
|
40358
41006
|
throw new Error(
|
|
40359
41007
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
40360
41008
|
);
|
|
@@ -40378,7 +41026,7 @@ var DataController = class {
|
|
|
40378
41026
|
}
|
|
40379
41027
|
}
|
|
40380
41028
|
`;
|
|
40381
|
-
const response = await fetch(
|
|
41029
|
+
const response = await fetch(endpoint, {
|
|
40382
41030
|
method: "POST",
|
|
40383
41031
|
headers: {
|
|
40384
41032
|
"Content-Type": "application/json"
|
|
@@ -40436,28 +41084,45 @@ var DataController = class {
|
|
|
40436
41084
|
}
|
|
40437
41085
|
}
|
|
40438
41086
|
/**
|
|
40439
|
-
* Retrieves a list of permissions granted by a user
|
|
41087
|
+
* Retrieves a list of permissions granted by a user.
|
|
40440
41088
|
*
|
|
40441
|
-
* This method
|
|
40442
|
-
*
|
|
40443
|
-
*
|
|
40444
|
-
*
|
|
40445
|
-
* 3. No need for additional contract calls as all data comes from subgraph
|
|
41089
|
+
* This method supports automatic fallback between subgraph and RPC modes:
|
|
41090
|
+
* - If subgraph URL is available, tries subgraph query first
|
|
41091
|
+
* - Falls back to direct contract queries via RPC if subgraph fails
|
|
41092
|
+
* - RPC mode uses gasAwareMulticall for efficient batch queries
|
|
40446
41093
|
*
|
|
40447
41094
|
* @param params - Object containing the user address and optional subgraph URL
|
|
40448
41095
|
* @param params.user - The wallet address of the user to query permissions for
|
|
40449
41096
|
* @param params.subgraphUrl - Optional subgraph URL to override the default
|
|
40450
41097
|
* @returns Promise resolving to an array of permission objects
|
|
40451
|
-
* @throws Error if subgraph
|
|
41098
|
+
* @throws Error if both subgraph and RPC queries fail
|
|
40452
41099
|
*/
|
|
40453
41100
|
async getUserPermissions(params) {
|
|
40454
41101
|
const { user, subgraphUrl } = params;
|
|
40455
|
-
const
|
|
40456
|
-
if (
|
|
40457
|
-
|
|
40458
|
-
|
|
40459
|
-
|
|
41102
|
+
const endpoint = subgraphUrl || this.context.subgraphUrl;
|
|
41103
|
+
if (endpoint) {
|
|
41104
|
+
try {
|
|
41105
|
+
const permissions = await this._getUserPermissionsViaSubgraph({
|
|
41106
|
+
user,
|
|
41107
|
+
subgraphUrl: endpoint
|
|
41108
|
+
});
|
|
41109
|
+
return permissions;
|
|
41110
|
+
} catch (error) {
|
|
41111
|
+
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
41112
|
+
}
|
|
40460
41113
|
}
|
|
41114
|
+
return await this._getUserPermissionsViaRpc({ user });
|
|
41115
|
+
}
|
|
41116
|
+
/**
|
|
41117
|
+
* Internal method: Query user permissions via subgraph
|
|
41118
|
+
*
|
|
41119
|
+
* @param params - Query parameters object
|
|
41120
|
+
* @param params.user - The user address to query permissions for
|
|
41121
|
+
* @param params.subgraphUrl - The subgraph URL endpoint to query
|
|
41122
|
+
* @returns Promise resolving to an array of permission objects
|
|
41123
|
+
*/
|
|
41124
|
+
async _getUserPermissionsViaSubgraph(params) {
|
|
41125
|
+
const { user, subgraphUrl } = params;
|
|
40461
41126
|
try {
|
|
40462
41127
|
const query = `
|
|
40463
41128
|
query GetUserPermissions($userId: ID!) {
|
|
@@ -40478,7 +41143,7 @@ var DataController = class {
|
|
|
40478
41143
|
}
|
|
40479
41144
|
}
|
|
40480
41145
|
`;
|
|
40481
|
-
const response = await fetch(
|
|
41146
|
+
const response = await fetch(subgraphUrl, {
|
|
40482
41147
|
method: "POST",
|
|
40483
41148
|
headers: {
|
|
40484
41149
|
"Content-Type": "application/json"
|
|
@@ -40498,15 +41163,14 @@ var DataController = class {
|
|
|
40498
41163
|
const result = await response.json();
|
|
40499
41164
|
if (result.errors) {
|
|
40500
41165
|
throw new Error(
|
|
40501
|
-
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
41166
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
40502
41167
|
);
|
|
40503
41168
|
}
|
|
40504
41169
|
const userData = result.data?.user;
|
|
40505
41170
|
if (!userData || !userData.permissions?.length) {
|
|
40506
|
-
console.warn("No permissions found for user:", user);
|
|
40507
41171
|
return [];
|
|
40508
41172
|
}
|
|
40509
|
-
|
|
41173
|
+
return userData.permissions.map((permission) => ({
|
|
40510
41174
|
id: permission.id,
|
|
40511
41175
|
grant: permission.grant,
|
|
40512
41176
|
nonce: BigInt(permission.nonce),
|
|
@@ -40516,131 +41180,158 @@ var DataController = class {
|
|
|
40516
41180
|
transactionHash: permission.transactionHash,
|
|
40517
41181
|
user: permission.user.id
|
|
40518
41182
|
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
41183
|
+
} catch (error) {
|
|
41184
|
+
console.error("Failed to query user permissions from subgraph:", error);
|
|
41185
|
+
throw error;
|
|
41186
|
+
}
|
|
41187
|
+
}
|
|
41188
|
+
/**
|
|
41189
|
+
* Internal method: Query user permissions via direct RPC
|
|
41190
|
+
*
|
|
41191
|
+
* @param params - Query parameters object
|
|
41192
|
+
* @param params.user - The user address to query permissions for
|
|
41193
|
+
* @returns Promise resolving to an array of permission objects
|
|
41194
|
+
*/
|
|
41195
|
+
async _getUserPermissionsViaRpc(params) {
|
|
41196
|
+
const { user } = params;
|
|
41197
|
+
try {
|
|
41198
|
+
const chainId = this.context.walletClient.chain?.id;
|
|
41199
|
+
if (!chainId) {
|
|
41200
|
+
throw new Error("Chain ID not available");
|
|
41201
|
+
}
|
|
41202
|
+
const permissionsAddress = getContractAddress(
|
|
41203
|
+
chainId,
|
|
41204
|
+
"DataPortabilityPermissions"
|
|
41205
|
+
);
|
|
41206
|
+
const permissionsAbi = getAbi("DataPortabilityPermissions");
|
|
41207
|
+
const totalCount = await this.context.publicClient.readContract({
|
|
41208
|
+
address: permissionsAddress,
|
|
41209
|
+
abi: permissionsAbi,
|
|
41210
|
+
functionName: "userPermissionIdsLength",
|
|
41211
|
+
args: [user]
|
|
41212
|
+
});
|
|
41213
|
+
const total = Number(totalCount);
|
|
41214
|
+
if (total === 0) {
|
|
41215
|
+
return [];
|
|
41216
|
+
}
|
|
41217
|
+
const permissionIdCalls = [];
|
|
41218
|
+
for (let i = 0; i < total; i++) {
|
|
41219
|
+
permissionIdCalls.push({
|
|
41220
|
+
address: permissionsAddress,
|
|
41221
|
+
abi: permissionsAbi,
|
|
41222
|
+
functionName: "userPermissionIdsAt",
|
|
41223
|
+
args: [user, BigInt(i)]
|
|
41224
|
+
});
|
|
41225
|
+
}
|
|
41226
|
+
const permissionIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41227
|
+
contracts: permissionIdCalls
|
|
41228
|
+
});
|
|
41229
|
+
const permissionIds = permissionIdResults.map((result) => result).filter((id) => id && id > 0n);
|
|
41230
|
+
const permissionInfoCalls = permissionIds.map(
|
|
41231
|
+
(permissionId) => ({
|
|
41232
|
+
address: permissionsAddress,
|
|
41233
|
+
abi: permissionsAbi,
|
|
41234
|
+
functionName: "permissions",
|
|
41235
|
+
args: [permissionId]
|
|
41236
|
+
})
|
|
41237
|
+
);
|
|
41238
|
+
const permissionInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41239
|
+
contracts: permissionInfoCalls,
|
|
41240
|
+
allowFailure: true
|
|
41241
|
+
});
|
|
41242
|
+
const permissions = permissionInfoResults.map((result, index) => {
|
|
41243
|
+
const permissionId = permissionIds[index];
|
|
41244
|
+
if (result.status === "success" && result.result) {
|
|
41245
|
+
const permissionInfo = result.result;
|
|
41246
|
+
return {
|
|
41247
|
+
id: permissionId.toString(),
|
|
41248
|
+
grant: permissionInfo.grant,
|
|
41249
|
+
nonce: permissionInfo.nonce,
|
|
41250
|
+
signature: "",
|
|
41251
|
+
// Not available from RPC, will be empty
|
|
41252
|
+
addedAtBlock: permissionInfo.startBlock,
|
|
41253
|
+
addedAtTimestamp: BigInt(0),
|
|
41254
|
+
// Not available from RPC
|
|
41255
|
+
transactionHash: "0x0000000000000000000000000000000000000000",
|
|
41256
|
+
// Not available from RPC
|
|
41257
|
+
user
|
|
41258
|
+
};
|
|
41259
|
+
} else {
|
|
41260
|
+
return {
|
|
41261
|
+
id: permissionId.toString(),
|
|
41262
|
+
grant: "",
|
|
41263
|
+
nonce: BigInt(0),
|
|
41264
|
+
signature: "",
|
|
41265
|
+
addedAtBlock: BigInt(0),
|
|
41266
|
+
addedAtTimestamp: BigInt(0),
|
|
41267
|
+
transactionHash: "0x0000000000000000000000000000000000000000",
|
|
41268
|
+
user
|
|
41269
|
+
};
|
|
41270
|
+
}
|
|
41271
|
+
}).filter((permission) => permission.grant !== "");
|
|
40519
41272
|
return permissions;
|
|
40520
41273
|
} catch (error) {
|
|
40521
|
-
console.error("Failed to fetch user permissions from subgraph:", error);
|
|
40522
41274
|
throw new Error(
|
|
40523
|
-
`
|
|
41275
|
+
`RPC query failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40524
41276
|
);
|
|
40525
41277
|
}
|
|
40526
41278
|
}
|
|
40527
41279
|
/**
|
|
40528
|
-
* Retrieves a list of trusted servers for a user
|
|
41280
|
+
* Retrieves a list of trusted servers for a user.
|
|
40529
41281
|
*
|
|
40530
|
-
* This method
|
|
40531
|
-
*
|
|
41282
|
+
* This method supports automatic fallback between subgraph and RPC modes:
|
|
41283
|
+
* - If subgraph URL is available, tries subgraph query first for fast results
|
|
41284
|
+
* - Falls back to direct contract queries via RPC if subgraph fails
|
|
41285
|
+
* - RPC mode uses gasAwareMulticall for efficient batch queries
|
|
40532
41286
|
*
|
|
40533
|
-
*
|
|
40534
|
-
* -
|
|
40535
|
-
*
|
|
40536
|
-
* -
|
|
40537
|
-
*
|
|
40538
|
-
* @
|
|
40539
|
-
* @
|
|
40540
|
-
* @throws Error if query fails in both modes (when using 'auto')
|
|
41287
|
+
* @param params - Query parameters including user address and optional pagination
|
|
41288
|
+
* @param params.user - The wallet address of the user to query trusted servers for
|
|
41289
|
+
* @param params.subgraphUrl - Optional subgraph URL to override the default
|
|
41290
|
+
* @param params.limit - Maximum number of results to return (default: 50)
|
|
41291
|
+
* @param params.offset - Number of results to skip for pagination (default: 0)
|
|
41292
|
+
* @returns Promise resolving to an array of trusted server objects
|
|
41293
|
+
* @throws Error if both subgraph and RPC queries fail
|
|
40541
41294
|
* @example
|
|
40542
41295
|
* ```typescript
|
|
40543
|
-
* //
|
|
40544
|
-
* const
|
|
40545
|
-
* user: '0x...'
|
|
40546
|
-
* mode: 'subgraph',
|
|
40547
|
-
* subgraphUrl: 'https://...'
|
|
41296
|
+
* // Basic usage with automatic fallback
|
|
41297
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
41298
|
+
* user: '0x...'
|
|
40548
41299
|
* });
|
|
40549
41300
|
*
|
|
40550
|
-
* //
|
|
40551
|
-
* const
|
|
41301
|
+
* // With pagination
|
|
41302
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
40552
41303
|
* user: '0x...',
|
|
40553
|
-
*
|
|
40554
|
-
*
|
|
41304
|
+
* limit: 10,
|
|
41305
|
+
* offset: 20
|
|
40555
41306
|
* });
|
|
40556
41307
|
*
|
|
40557
|
-
* //
|
|
40558
|
-
* const
|
|
41308
|
+
* // With custom subgraph URL
|
|
41309
|
+
* const servers = await vana.data.getUserTrustedServers({
|
|
40559
41310
|
* user: '0x...',
|
|
40560
|
-
*
|
|
41311
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
40561
41312
|
* });
|
|
40562
41313
|
* ```
|
|
40563
41314
|
*/
|
|
40564
41315
|
async getUserTrustedServers(params) {
|
|
40565
|
-
const { user,
|
|
40566
|
-
const
|
|
40567
|
-
|
|
40568
|
-
let tryRpc = false;
|
|
40569
|
-
switch (mode) {
|
|
40570
|
-
case "subgraph":
|
|
40571
|
-
trySubgraph = true;
|
|
40572
|
-
break;
|
|
40573
|
-
case "rpc":
|
|
40574
|
-
tryRpc = true;
|
|
40575
|
-
break;
|
|
40576
|
-
case "auto":
|
|
40577
|
-
trySubgraph = true;
|
|
40578
|
-
tryRpc = true;
|
|
40579
|
-
break;
|
|
40580
|
-
}
|
|
40581
|
-
if (trySubgraph) {
|
|
40582
|
-
const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
|
|
40583
|
-
if (!subgraphUrl) {
|
|
40584
|
-
if (mode === "subgraph") {
|
|
40585
|
-
throw new Error(
|
|
40586
|
-
"subgraphUrl is required for subgraph mode. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
40587
|
-
);
|
|
40588
|
-
}
|
|
40589
|
-
warnings.push(
|
|
40590
|
-
"Subgraph mode not available for trusted servers - using direct contract calls"
|
|
40591
|
-
);
|
|
40592
|
-
} else {
|
|
40593
|
-
try {
|
|
40594
|
-
const servers = await this._getUserTrustedServersViaSubgraph({
|
|
40595
|
-
user,
|
|
40596
|
-
subgraphUrl
|
|
40597
|
-
});
|
|
40598
|
-
const paginatedServers = limit ? servers.slice(offset, offset + limit) : servers;
|
|
40599
|
-
return {
|
|
40600
|
-
servers: paginatedServers,
|
|
40601
|
-
usedMode: "subgraph",
|
|
40602
|
-
total: servers.length,
|
|
40603
|
-
hasMore: limit ? offset + limit < servers.length : false,
|
|
40604
|
-
warnings: warnings.length > 0 ? warnings : void 0
|
|
40605
|
-
};
|
|
40606
|
-
} catch (error) {
|
|
40607
|
-
if (mode === "subgraph") {
|
|
40608
|
-
throw error;
|
|
40609
|
-
}
|
|
40610
|
-
warnings.push(
|
|
40611
|
-
`Subgraph query failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40612
|
-
);
|
|
40613
|
-
console.warn(
|
|
40614
|
-
"Subgraph query failed, falling back to RPC mode:",
|
|
40615
|
-
error
|
|
40616
|
-
);
|
|
40617
|
-
}
|
|
40618
|
-
}
|
|
40619
|
-
}
|
|
40620
|
-
if (tryRpc) {
|
|
41316
|
+
const { user, limit = 50, offset = 0 } = params;
|
|
41317
|
+
const subgraphUrl = params.subgraphUrl || this.context.subgraphUrl;
|
|
41318
|
+
if (subgraphUrl) {
|
|
40621
41319
|
try {
|
|
40622
|
-
const
|
|
41320
|
+
const servers = await this._getUserTrustedServersViaSubgraph({
|
|
40623
41321
|
user,
|
|
40624
|
-
|
|
40625
|
-
offset
|
|
41322
|
+
subgraphUrl
|
|
40626
41323
|
});
|
|
40627
|
-
return
|
|
40628
|
-
servers: rpcResult.servers,
|
|
40629
|
-
usedMode: "rpc",
|
|
40630
|
-
total: rpcResult.total,
|
|
40631
|
-
hasMore: rpcResult.hasMore,
|
|
40632
|
-
warnings: warnings.length > 0 ? warnings : void 0
|
|
40633
|
-
};
|
|
41324
|
+
return limit ? servers.slice(offset, offset + limit) : servers;
|
|
40634
41325
|
} catch (error) {
|
|
40635
|
-
|
|
40636
|
-
throw error;
|
|
40637
|
-
}
|
|
40638
|
-
throw new Error(
|
|
40639
|
-
`Both query methods failed. Subgraph: ${warnings[0] || "Unknown error"}. RPC: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
40640
|
-
);
|
|
41326
|
+
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
40641
41327
|
}
|
|
40642
41328
|
}
|
|
40643
|
-
|
|
41329
|
+
const rpcResult = await this._getUserTrustedServersViaRpc({
|
|
41330
|
+
user,
|
|
41331
|
+
limit,
|
|
41332
|
+
offset
|
|
41333
|
+
});
|
|
41334
|
+
return rpcResult.servers;
|
|
40644
41335
|
}
|
|
40645
41336
|
/**
|
|
40646
41337
|
* Internal method: Query trusted servers via subgraph
|
|
@@ -40756,35 +41447,44 @@ var DataController = class {
|
|
|
40756
41447
|
};
|
|
40757
41448
|
}
|
|
40758
41449
|
const endIndex = Math.min(offset + limit, total);
|
|
40759
|
-
const
|
|
41450
|
+
const serverIdCalls = [];
|
|
40760
41451
|
for (let i = offset; i < endIndex; i++) {
|
|
40761
|
-
|
|
41452
|
+
serverIdCalls.push({
|
|
40762
41453
|
address: DataPortabilityServersAddress,
|
|
40763
41454
|
abi: DataPortabilityServersAbi,
|
|
40764
41455
|
functionName: "userServerIdsAt",
|
|
40765
41456
|
args: [user, BigInt(i)]
|
|
40766
41457
|
});
|
|
40767
|
-
serverIdPromises.push(promise);
|
|
40768
41458
|
}
|
|
40769
|
-
const
|
|
40770
|
-
|
|
40771
|
-
|
|
40772
|
-
|
|
40773
|
-
|
|
40774
|
-
|
|
40775
|
-
|
|
40776
|
-
|
|
40777
|
-
|
|
41459
|
+
const serverIdResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41460
|
+
contracts: serverIdCalls
|
|
41461
|
+
});
|
|
41462
|
+
const serverIds = serverIdResults.map((result) => result).filter((id) => id && id > 0n);
|
|
41463
|
+
const serverInfoCalls = serverIds.map(
|
|
41464
|
+
(serverId) => ({
|
|
41465
|
+
address: DataPortabilityServersAddress,
|
|
41466
|
+
abi: DataPortabilityServersAbi,
|
|
41467
|
+
functionName: "servers",
|
|
41468
|
+
args: [serverId]
|
|
41469
|
+
})
|
|
41470
|
+
);
|
|
41471
|
+
const serverInfoResults = await gasAwareMulticall(this.context.publicClient, {
|
|
41472
|
+
contracts: serverInfoCalls,
|
|
41473
|
+
allowFailure: true
|
|
41474
|
+
});
|
|
41475
|
+
const servers = serverInfoResults.map((result, index) => {
|
|
41476
|
+
const serverId = serverIds[index];
|
|
41477
|
+
if (result.status === "success" && result.result) {
|
|
41478
|
+
const serverInfo = result.result;
|
|
40778
41479
|
return {
|
|
40779
41480
|
id: `${user.toLowerCase()}-${serverId.toString()}`,
|
|
40780
41481
|
serverAddress: serverInfo.serverAddress,
|
|
40781
41482
|
serverUrl: serverInfo.url,
|
|
40782
41483
|
trustedAt: BigInt(Date.now()),
|
|
40783
|
-
// RPC mode doesn't have timestamp, use current time
|
|
40784
41484
|
user,
|
|
40785
41485
|
trustIndex: offset + index
|
|
40786
41486
|
};
|
|
40787
|
-
}
|
|
41487
|
+
} else {
|
|
40788
41488
|
return {
|
|
40789
41489
|
id: `${user.toLowerCase()}-${serverId.toString()}`,
|
|
40790
41490
|
serverAddress: "0x0000000000000000000000000000000000000000",
|
|
@@ -40795,7 +41495,6 @@ var DataController = class {
|
|
|
40795
41495
|
};
|
|
40796
41496
|
}
|
|
40797
41497
|
});
|
|
40798
|
-
const servers = await Promise.all(serverInfoPromises);
|
|
40799
41498
|
return {
|
|
40800
41499
|
servers,
|
|
40801
41500
|
total,
|
|
@@ -40830,7 +41529,7 @@ var DataController = class {
|
|
|
40830
41529
|
}
|
|
40831
41530
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
40832
41531
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
40833
|
-
const dataRegistry = (0,
|
|
41532
|
+
const dataRegistry = (0, import_viem5.getContract)({
|
|
40834
41533
|
address: dataRegistryAddress,
|
|
40835
41534
|
abi: dataRegistryAbi,
|
|
40836
41535
|
client: this.context.walletClient
|
|
@@ -40881,7 +41580,7 @@ var DataController = class {
|
|
|
40881
41580
|
}
|
|
40882
41581
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
40883
41582
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
40884
|
-
const dataRegistry = (0,
|
|
41583
|
+
const dataRegistry = (0, import_viem5.getContract)({
|
|
40885
41584
|
address: dataRegistryAddress,
|
|
40886
41585
|
abi: dataRegistryAbi,
|
|
40887
41586
|
client: this.context.walletClient
|
|
@@ -40922,12 +41621,25 @@ var DataController = class {
|
|
|
40922
41621
|
/**
|
|
40923
41622
|
* Registers a file URL directly on the blockchain with a schema ID.
|
|
40924
41623
|
*
|
|
40925
|
-
* @
|
|
41624
|
+
* @remarks
|
|
41625
|
+
* This method registers an existing file URL on the DataRegistry contract
|
|
41626
|
+
* with a schema ID, without uploading any data. Useful when you have already
|
|
41627
|
+
* uploaded content to storage and just need to register it on-chain.
|
|
41628
|
+
*
|
|
41629
|
+
* @param url - The URL of the file to register (IPFS or HTTP/HTTPS)
|
|
40926
41630
|
* @param schemaId - The schema ID to associate with the file
|
|
40927
41631
|
* @returns Promise resolving to the file ID and transaction hash
|
|
40928
|
-
*
|
|
40929
|
-
*
|
|
40930
|
-
*
|
|
41632
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41633
|
+
* @throws {Error} When wallet address is unavailable - "No addresses available"
|
|
41634
|
+
* @throws {Error} When transaction fails - "Failed to register file with schema"
|
|
41635
|
+
* @example
|
|
41636
|
+
* ```typescript
|
|
41637
|
+
* const { fileId, transactionHash } = await vana.data.registerFileWithSchema(
|
|
41638
|
+
* "ipfs://QmXxx...",
|
|
41639
|
+
* 1
|
|
41640
|
+
* );
|
|
41641
|
+
* console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
|
|
41642
|
+
* ```
|
|
40931
41643
|
*/
|
|
40932
41644
|
async registerFileWithSchema(url, schemaId) {
|
|
40933
41645
|
try {
|
|
@@ -40946,30 +41658,14 @@ var DataController = class {
|
|
|
40946
41658
|
account: this.context.walletClient.account || userAddress,
|
|
40947
41659
|
chain: this.context.walletClient.chain || null
|
|
40948
41660
|
});
|
|
40949
|
-
const
|
|
40950
|
-
|
|
40951
|
-
|
|
40952
|
-
|
|
40953
|
-
}
|
|
41661
|
+
const txHandle = new TransactionHandle(
|
|
41662
|
+
this.context,
|
|
41663
|
+
txHash,
|
|
41664
|
+
"addFileWithSchema"
|
|
40954
41665
|
);
|
|
40955
|
-
|
|
40956
|
-
for (const log of receipt.logs) {
|
|
40957
|
-
try {
|
|
40958
|
-
const decoded = (0, import_viem4.decodeEventLog)({
|
|
40959
|
-
abi: dataRegistryAbi,
|
|
40960
|
-
data: log.data,
|
|
40961
|
-
topics: log.topics
|
|
40962
|
-
});
|
|
40963
|
-
if (decoded.eventName === "FileAdded") {
|
|
40964
|
-
fileId = Number(decoded.args.fileId);
|
|
40965
|
-
break;
|
|
40966
|
-
}
|
|
40967
|
-
} catch {
|
|
40968
|
-
continue;
|
|
40969
|
-
}
|
|
40970
|
-
}
|
|
41666
|
+
const result = await txHandle.waitForEvents();
|
|
40971
41667
|
return {
|
|
40972
|
-
fileId,
|
|
41668
|
+
fileId: Number(result.fileId),
|
|
40973
41669
|
transactionHash: txHash
|
|
40974
41670
|
};
|
|
40975
41671
|
} catch (error) {
|
|
@@ -41024,31 +41720,14 @@ var DataController = class {
|
|
|
41024
41720
|
account: this.context.walletClient.account || ownerAddress,
|
|
41025
41721
|
chain: this.context.walletClient.chain || null
|
|
41026
41722
|
});
|
|
41027
|
-
const
|
|
41028
|
-
|
|
41029
|
-
|
|
41030
|
-
|
|
41031
|
-
// 30 seconds timeout
|
|
41032
|
-
}
|
|
41723
|
+
const txHandle = new TransactionHandle(
|
|
41724
|
+
this.context,
|
|
41725
|
+
txHash,
|
|
41726
|
+
"addFileWithPermissions"
|
|
41033
41727
|
);
|
|
41034
|
-
|
|
41035
|
-
for (const log of receipt.logs) {
|
|
41036
|
-
try {
|
|
41037
|
-
const decoded = (0, import_viem4.decodeEventLog)({
|
|
41038
|
-
abi: dataRegistryAbi,
|
|
41039
|
-
data: log.data,
|
|
41040
|
-
topics: log.topics
|
|
41041
|
-
});
|
|
41042
|
-
if (decoded.eventName === "FileAdded") {
|
|
41043
|
-
fileId = Number(decoded.args.fileId);
|
|
41044
|
-
break;
|
|
41045
|
-
}
|
|
41046
|
-
} catch {
|
|
41047
|
-
continue;
|
|
41048
|
-
}
|
|
41049
|
-
}
|
|
41728
|
+
const result = await txHandle.waitForEvents();
|
|
41050
41729
|
return {
|
|
41051
|
-
fileId,
|
|
41730
|
+
fileId: Number(result.fileId),
|
|
41052
41731
|
transactionHash: txHash
|
|
41053
41732
|
};
|
|
41054
41733
|
} catch (error) {
|
|
@@ -41088,31 +41767,14 @@ var DataController = class {
|
|
|
41088
41767
|
account: this.context.walletClient.account || ownerAddress,
|
|
41089
41768
|
chain: this.context.walletClient.chain || null
|
|
41090
41769
|
});
|
|
41091
|
-
const
|
|
41092
|
-
|
|
41093
|
-
|
|
41094
|
-
|
|
41095
|
-
// 30 seconds timeout
|
|
41096
|
-
}
|
|
41770
|
+
const txHandle = new TransactionHandle(
|
|
41771
|
+
this.context,
|
|
41772
|
+
txHash,
|
|
41773
|
+
"addFileWithPermissionsAndSchema"
|
|
41097
41774
|
);
|
|
41098
|
-
|
|
41099
|
-
for (const log of receipt.logs) {
|
|
41100
|
-
try {
|
|
41101
|
-
const decoded = (0, import_viem4.decodeEventLog)({
|
|
41102
|
-
abi: dataRegistryAbi,
|
|
41103
|
-
data: log.data,
|
|
41104
|
-
topics: log.topics
|
|
41105
|
-
});
|
|
41106
|
-
if (decoded.eventName === "FileAdded") {
|
|
41107
|
-
fileId = Number(decoded.args.fileId);
|
|
41108
|
-
break;
|
|
41109
|
-
}
|
|
41110
|
-
} catch {
|
|
41111
|
-
continue;
|
|
41112
|
-
}
|
|
41113
|
-
}
|
|
41775
|
+
const result = await txHandle.waitForEvents();
|
|
41114
41776
|
return {
|
|
41115
|
-
fileId,
|
|
41777
|
+
fileId: Number(result.fileId),
|
|
41116
41778
|
transactionHash: txHash
|
|
41117
41779
|
};
|
|
41118
41780
|
} catch (error) {
|
|
@@ -41125,8 +41787,30 @@ var DataController = class {
|
|
|
41125
41787
|
/**
|
|
41126
41788
|
* Adds a new refiner to the DataRefinerRegistry.
|
|
41127
41789
|
*
|
|
41128
|
-
* @
|
|
41790
|
+
* @remarks
|
|
41791
|
+
* Refiners are data processing templates that define how raw data should be
|
|
41792
|
+
* transformed into structured formats. Each refiner is associated with a DLP
|
|
41793
|
+
* (Data Liquidity Pool), has a specific schema for output, and includes
|
|
41794
|
+
* instructions for the refinement process.
|
|
41795
|
+
*
|
|
41796
|
+
* @param params - Refiner configuration parameters
|
|
41797
|
+
* @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
|
|
41798
|
+
* @param params.name - Human-readable name for the refiner
|
|
41799
|
+
* @param params.schemaId - Schema ID that defines the output format
|
|
41800
|
+
* @param params.refinementInstructionUrl - URL containing processing instructions
|
|
41129
41801
|
* @returns Promise resolving to the new refiner ID and transaction hash
|
|
41802
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41803
|
+
* @throws {Error} When transaction fails - "Failed to add refiner: {error}"
|
|
41804
|
+
* @example
|
|
41805
|
+
* ```typescript
|
|
41806
|
+
* const result = await vana.data.addRefiner({
|
|
41807
|
+
* dlpId: 1,
|
|
41808
|
+
* name: "Social Media Sentiment Analyzer",
|
|
41809
|
+
* schemaId: 42,
|
|
41810
|
+
* refinementInstructionUrl: "ipfs://QmXxx..."
|
|
41811
|
+
* });
|
|
41812
|
+
* console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
|
|
41813
|
+
* ```
|
|
41130
41814
|
*/
|
|
41131
41815
|
async addRefiner(params) {
|
|
41132
41816
|
try {
|
|
@@ -41152,30 +41836,14 @@ var DataController = class {
|
|
|
41152
41836
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
41153
41837
|
chain: this.context.walletClient.chain || null
|
|
41154
41838
|
});
|
|
41155
|
-
const
|
|
41156
|
-
|
|
41157
|
-
|
|
41158
|
-
|
|
41159
|
-
}
|
|
41839
|
+
const txHandle = new TransactionHandle(
|
|
41840
|
+
this.context,
|
|
41841
|
+
txHash,
|
|
41842
|
+
"addRefiner"
|
|
41160
41843
|
);
|
|
41161
|
-
|
|
41162
|
-
for (const log of receipt.logs) {
|
|
41163
|
-
try {
|
|
41164
|
-
const decoded = (0, import_viem4.decodeEventLog)({
|
|
41165
|
-
abi: dataRefinerRegistryAbi,
|
|
41166
|
-
data: log.data,
|
|
41167
|
-
topics: log.topics
|
|
41168
|
-
});
|
|
41169
|
-
if (decoded.eventName === "RefinerAdded") {
|
|
41170
|
-
refinerId = Number(decoded.args.refinerId);
|
|
41171
|
-
break;
|
|
41172
|
-
}
|
|
41173
|
-
} catch {
|
|
41174
|
-
continue;
|
|
41175
|
-
}
|
|
41176
|
-
}
|
|
41844
|
+
const result = await txHandle.waitForEvents();
|
|
41177
41845
|
return {
|
|
41178
|
-
refinerId,
|
|
41846
|
+
refinerId: Number(result.refinerId),
|
|
41179
41847
|
transactionHash: txHash
|
|
41180
41848
|
};
|
|
41181
41849
|
} catch (error) {
|
|
@@ -41188,8 +41856,25 @@ var DataController = class {
|
|
|
41188
41856
|
/**
|
|
41189
41857
|
* Retrieves a refiner by its ID.
|
|
41190
41858
|
*
|
|
41191
|
-
* @
|
|
41192
|
-
*
|
|
41859
|
+
* @remarks
|
|
41860
|
+
* Queries the DataRefinerRegistry contract to get complete information about
|
|
41861
|
+
* a specific refiner including its DLP association, schema, and instructions.
|
|
41862
|
+
*
|
|
41863
|
+
* @param refinerId - The numeric refiner ID to retrieve
|
|
41864
|
+
* @returns Promise resolving to the refiner information object
|
|
41865
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
41866
|
+
* @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
|
|
41867
|
+
* @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
|
|
41868
|
+
* @example
|
|
41869
|
+
* ```typescript
|
|
41870
|
+
* const refiner = await vana.data.getRefiner(1);
|
|
41871
|
+
* console.log({
|
|
41872
|
+
* name: refiner.name,
|
|
41873
|
+
* dlp: refiner.dlpId,
|
|
41874
|
+
* schema: refiner.schemaId,
|
|
41875
|
+
* instructions: refiner.refinementInstructionUrl
|
|
41876
|
+
* });
|
|
41877
|
+
* ```
|
|
41193
41878
|
*/
|
|
41194
41879
|
async getRefiner(refinerId) {
|
|
41195
41880
|
try {
|
|
@@ -41202,7 +41887,7 @@ var DataController = class {
|
|
|
41202
41887
|
"DataRefinerRegistry"
|
|
41203
41888
|
);
|
|
41204
41889
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
41205
|
-
const dataRefinerRegistry = (0,
|
|
41890
|
+
const dataRefinerRegistry = (0, import_viem5.getContract)({
|
|
41206
41891
|
address: dataRefinerRegistryAddress,
|
|
41207
41892
|
abi: dataRefinerRegistryAbi,
|
|
41208
41893
|
client: this.context.walletClient
|
|
@@ -41231,8 +41916,21 @@ var DataController = class {
|
|
|
41231
41916
|
/**
|
|
41232
41917
|
* Validates if a schema ID exists in the registry.
|
|
41233
41918
|
*
|
|
41234
|
-
* @
|
|
41235
|
-
*
|
|
41919
|
+
* @remarks
|
|
41920
|
+
* Checks the DataRefinerRegistry contract to determine if a given schema ID
|
|
41921
|
+
* has been registered and is available for use.
|
|
41922
|
+
*
|
|
41923
|
+
* @param schemaId - The numeric schema ID to validate
|
|
41924
|
+
* @returns Promise resolving to true if schema exists, false otherwise
|
|
41925
|
+
* @example
|
|
41926
|
+
* ```typescript
|
|
41927
|
+
* const isValid = await vana.data.isValidSchemaId(42);
|
|
41928
|
+
* if (isValid) {
|
|
41929
|
+
* console.log('Schema 42 is available for use');
|
|
41930
|
+
* } else {
|
|
41931
|
+
* console.log('Schema 42 does not exist');
|
|
41932
|
+
* }
|
|
41933
|
+
* ```
|
|
41236
41934
|
*/
|
|
41237
41935
|
async isValidSchemaId(schemaId) {
|
|
41238
41936
|
try {
|
|
@@ -41245,7 +41943,7 @@ var DataController = class {
|
|
|
41245
41943
|
"DataRefinerRegistry"
|
|
41246
41944
|
);
|
|
41247
41945
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
41248
|
-
const dataRefinerRegistry = (0,
|
|
41946
|
+
const dataRefinerRegistry = (0, import_viem5.getContract)({
|
|
41249
41947
|
address: dataRefinerRegistryAddress,
|
|
41250
41948
|
abi: dataRefinerRegistryAbi,
|
|
41251
41949
|
client: this.context.walletClient
|
|
@@ -41262,7 +41960,16 @@ var DataController = class {
|
|
|
41262
41960
|
/**
|
|
41263
41961
|
* Gets the total number of refiners in the registry.
|
|
41264
41962
|
*
|
|
41963
|
+
* @remarks
|
|
41964
|
+
* Queries the DataRefinerRegistry contract to get the total count of all
|
|
41965
|
+
* registered refiners across all DLPs.
|
|
41966
|
+
*
|
|
41265
41967
|
* @returns Promise resolving to the total refiner count
|
|
41968
|
+
* @example
|
|
41969
|
+
* ```typescript
|
|
41970
|
+
* const count = await vana.data.getRefinersCount();
|
|
41971
|
+
* console.log(`Total refiners registered: ${count}`);
|
|
41972
|
+
* ```
|
|
41266
41973
|
*/
|
|
41267
41974
|
async getRefinersCount() {
|
|
41268
41975
|
try {
|
|
@@ -41275,7 +41982,7 @@ var DataController = class {
|
|
|
41275
41982
|
"DataRefinerRegistry"
|
|
41276
41983
|
);
|
|
41277
41984
|
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
41278
|
-
const dataRefinerRegistry = (0,
|
|
41985
|
+
const dataRefinerRegistry = (0, import_viem5.getContract)({
|
|
41279
41986
|
address: dataRefinerRegistryAddress,
|
|
41280
41987
|
abi: dataRefinerRegistryAbi,
|
|
41281
41988
|
client: this.context.walletClient
|
|
@@ -41290,8 +41997,24 @@ var DataController = class {
|
|
|
41290
41997
|
/**
|
|
41291
41998
|
* Updates the schema ID for an existing refiner.
|
|
41292
41999
|
*
|
|
41293
|
-
* @
|
|
42000
|
+
* @remarks
|
|
42001
|
+
* Allows the owner of a refiner to update its associated schema ID.
|
|
42002
|
+
* This is useful when refiner output format needs to change.
|
|
42003
|
+
*
|
|
42004
|
+
* @param params - Update parameters
|
|
42005
|
+
* @param params.refinerId - The refiner ID to update
|
|
42006
|
+
* @param params.newSchemaId - The new schema ID to set
|
|
41294
42007
|
* @returns Promise resolving to the transaction hash
|
|
42008
|
+
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
42009
|
+
* @throws {Error} When transaction fails - "Failed to update schema ID: {error}"
|
|
42010
|
+
* @example
|
|
42011
|
+
* ```typescript
|
|
42012
|
+
* const result = await vana.data.updateSchemaId({
|
|
42013
|
+
* refinerId: 1,
|
|
42014
|
+
* newSchemaId: 55
|
|
42015
|
+
* });
|
|
42016
|
+
* console.log(`Schema updated in tx ${result.transactionHash}`);
|
|
42017
|
+
* ```
|
|
41295
42018
|
*/
|
|
41296
42019
|
async updateSchemaId(params) {
|
|
41297
42020
|
try {
|
|
@@ -41487,8 +42210,7 @@ var DataController = class {
|
|
|
41487
42210
|
* ```
|
|
41488
42211
|
*/
|
|
41489
42212
|
async addPermissionToFile(fileId, account, publicKey) {
|
|
41490
|
-
|
|
41491
|
-
return parseTransactionResult(this.context, txHash, "addFilePermission");
|
|
42213
|
+
return await this.submitFilePermission(fileId, account, publicKey);
|
|
41492
42214
|
}
|
|
41493
42215
|
/**
|
|
41494
42216
|
* Submits a file permission transaction and returns the transaction hash immediately.
|
|
@@ -41532,7 +42254,11 @@ var DataController = class {
|
|
|
41532
42254
|
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
41533
42255
|
chain: this.context.walletClient.chain || null
|
|
41534
42256
|
});
|
|
41535
|
-
return
|
|
42257
|
+
return new TransactionHandle(
|
|
42258
|
+
this.context,
|
|
42259
|
+
txHash,
|
|
42260
|
+
"addFilePermission"
|
|
42261
|
+
);
|
|
41536
42262
|
} catch (error) {
|
|
41537
42263
|
console.error("Failed to add permission to file:", error);
|
|
41538
42264
|
throw new Error(
|
|
@@ -41555,7 +42281,7 @@ var DataController = class {
|
|
|
41555
42281
|
}
|
|
41556
42282
|
const dataRegistryAddress = getContractAddress(chainId, "DataRegistry");
|
|
41557
42283
|
const dataRegistryAbi = getAbi("DataRegistry");
|
|
41558
|
-
const dataRegistry = (0,
|
|
42284
|
+
const dataRegistry = (0, import_viem5.getContract)({
|
|
41559
42285
|
address: dataRegistryAddress,
|
|
41560
42286
|
abi: dataRegistryAbi,
|
|
41561
42287
|
client: this.context.walletClient
|
|
@@ -41903,8 +42629,203 @@ var DataController = class {
|
|
|
41903
42629
|
}
|
|
41904
42630
|
};
|
|
41905
42631
|
|
|
42632
|
+
// src/generated/subgraph.ts
|
|
42633
|
+
var GetSchemaDocument = {
|
|
42634
|
+
kind: "Document",
|
|
42635
|
+
definitions: [
|
|
42636
|
+
{
|
|
42637
|
+
kind: "OperationDefinition",
|
|
42638
|
+
operation: "query",
|
|
42639
|
+
name: { kind: "Name", value: "GetSchema" },
|
|
42640
|
+
variableDefinitions: [
|
|
42641
|
+
{
|
|
42642
|
+
kind: "VariableDefinition",
|
|
42643
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
42644
|
+
type: {
|
|
42645
|
+
kind: "NonNullType",
|
|
42646
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "ID" } }
|
|
42647
|
+
}
|
|
42648
|
+
}
|
|
42649
|
+
],
|
|
42650
|
+
selectionSet: {
|
|
42651
|
+
kind: "SelectionSet",
|
|
42652
|
+
selections: [
|
|
42653
|
+
{
|
|
42654
|
+
kind: "Field",
|
|
42655
|
+
name: { kind: "Name", value: "schema" },
|
|
42656
|
+
arguments: [
|
|
42657
|
+
{
|
|
42658
|
+
kind: "Argument",
|
|
42659
|
+
name: { kind: "Name", value: "id" },
|
|
42660
|
+
value: {
|
|
42661
|
+
kind: "Variable",
|
|
42662
|
+
name: { kind: "Name", value: "id" }
|
|
42663
|
+
}
|
|
42664
|
+
}
|
|
42665
|
+
],
|
|
42666
|
+
selectionSet: {
|
|
42667
|
+
kind: "SelectionSet",
|
|
42668
|
+
selections: [
|
|
42669
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42670
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42671
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
42672
|
+
{
|
|
42673
|
+
kind: "Field",
|
|
42674
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
42675
|
+
},
|
|
42676
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
42677
|
+
{
|
|
42678
|
+
kind: "Field",
|
|
42679
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
42680
|
+
},
|
|
42681
|
+
{
|
|
42682
|
+
kind: "Field",
|
|
42683
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
42684
|
+
},
|
|
42685
|
+
{
|
|
42686
|
+
kind: "Field",
|
|
42687
|
+
name: { kind: "Name", value: "refiners" },
|
|
42688
|
+
selectionSet: {
|
|
42689
|
+
kind: "SelectionSet",
|
|
42690
|
+
selections: [
|
|
42691
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42692
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42693
|
+
{ kind: "Field", name: { kind: "Name", value: "owner" } }
|
|
42694
|
+
]
|
|
42695
|
+
}
|
|
42696
|
+
}
|
|
42697
|
+
]
|
|
42698
|
+
}
|
|
42699
|
+
}
|
|
42700
|
+
]
|
|
42701
|
+
}
|
|
42702
|
+
}
|
|
42703
|
+
]
|
|
42704
|
+
};
|
|
42705
|
+
var ListSchemasDocument = {
|
|
42706
|
+
kind: "Document",
|
|
42707
|
+
definitions: [
|
|
42708
|
+
{
|
|
42709
|
+
kind: "OperationDefinition",
|
|
42710
|
+
operation: "query",
|
|
42711
|
+
name: { kind: "Name", value: "ListSchemas" },
|
|
42712
|
+
variableDefinitions: [
|
|
42713
|
+
{
|
|
42714
|
+
kind: "VariableDefinition",
|
|
42715
|
+
variable: {
|
|
42716
|
+
kind: "Variable",
|
|
42717
|
+
name: { kind: "Name", value: "first" }
|
|
42718
|
+
},
|
|
42719
|
+
type: {
|
|
42720
|
+
kind: "NonNullType",
|
|
42721
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
42722
|
+
}
|
|
42723
|
+
},
|
|
42724
|
+
{
|
|
42725
|
+
kind: "VariableDefinition",
|
|
42726
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "skip" } },
|
|
42727
|
+
type: {
|
|
42728
|
+
kind: "NonNullType",
|
|
42729
|
+
type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }
|
|
42730
|
+
}
|
|
42731
|
+
}
|
|
42732
|
+
],
|
|
42733
|
+
selectionSet: {
|
|
42734
|
+
kind: "SelectionSet",
|
|
42735
|
+
selections: [
|
|
42736
|
+
{
|
|
42737
|
+
kind: "Field",
|
|
42738
|
+
name: { kind: "Name", value: "schemas" },
|
|
42739
|
+
arguments: [
|
|
42740
|
+
{
|
|
42741
|
+
kind: "Argument",
|
|
42742
|
+
name: { kind: "Name", value: "first" },
|
|
42743
|
+
value: {
|
|
42744
|
+
kind: "Variable",
|
|
42745
|
+
name: { kind: "Name", value: "first" }
|
|
42746
|
+
}
|
|
42747
|
+
},
|
|
42748
|
+
{
|
|
42749
|
+
kind: "Argument",
|
|
42750
|
+
name: { kind: "Name", value: "skip" },
|
|
42751
|
+
value: {
|
|
42752
|
+
kind: "Variable",
|
|
42753
|
+
name: { kind: "Name", value: "skip" }
|
|
42754
|
+
}
|
|
42755
|
+
},
|
|
42756
|
+
{
|
|
42757
|
+
kind: "Argument",
|
|
42758
|
+
name: { kind: "Name", value: "orderBy" },
|
|
42759
|
+
value: { kind: "EnumValue", value: "createdAt" }
|
|
42760
|
+
},
|
|
42761
|
+
{
|
|
42762
|
+
kind: "Argument",
|
|
42763
|
+
name: { kind: "Name", value: "orderDirection" },
|
|
42764
|
+
value: { kind: "EnumValue", value: "desc" }
|
|
42765
|
+
}
|
|
42766
|
+
],
|
|
42767
|
+
selectionSet: {
|
|
42768
|
+
kind: "SelectionSet",
|
|
42769
|
+
selections: [
|
|
42770
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } },
|
|
42771
|
+
{ kind: "Field", name: { kind: "Name", value: "name" } },
|
|
42772
|
+
{ kind: "Field", name: { kind: "Name", value: "dialect" } },
|
|
42773
|
+
{
|
|
42774
|
+
kind: "Field",
|
|
42775
|
+
name: { kind: "Name", value: "definitionUrl" }
|
|
42776
|
+
},
|
|
42777
|
+
{ kind: "Field", name: { kind: "Name", value: "createdAt" } },
|
|
42778
|
+
{
|
|
42779
|
+
kind: "Field",
|
|
42780
|
+
name: { kind: "Name", value: "createdAtBlock" }
|
|
42781
|
+
},
|
|
42782
|
+
{
|
|
42783
|
+
kind: "Field",
|
|
42784
|
+
name: { kind: "Name", value: "createdTxHash" }
|
|
42785
|
+
}
|
|
42786
|
+
]
|
|
42787
|
+
}
|
|
42788
|
+
}
|
|
42789
|
+
]
|
|
42790
|
+
}
|
|
42791
|
+
}
|
|
42792
|
+
]
|
|
42793
|
+
};
|
|
42794
|
+
var CountSchemasDocument = {
|
|
42795
|
+
kind: "Document",
|
|
42796
|
+
definitions: [
|
|
42797
|
+
{
|
|
42798
|
+
kind: "OperationDefinition",
|
|
42799
|
+
operation: "query",
|
|
42800
|
+
name: { kind: "Name", value: "CountSchemas" },
|
|
42801
|
+
selectionSet: {
|
|
42802
|
+
kind: "SelectionSet",
|
|
42803
|
+
selections: [
|
|
42804
|
+
{
|
|
42805
|
+
kind: "Field",
|
|
42806
|
+
name: { kind: "Name", value: "schemas" },
|
|
42807
|
+
arguments: [
|
|
42808
|
+
{
|
|
42809
|
+
kind: "Argument",
|
|
42810
|
+
name: { kind: "Name", value: "first" },
|
|
42811
|
+
value: { kind: "IntValue", value: "1000" }
|
|
42812
|
+
}
|
|
42813
|
+
],
|
|
42814
|
+
selectionSet: {
|
|
42815
|
+
kind: "SelectionSet",
|
|
42816
|
+
selections: [
|
|
42817
|
+
{ kind: "Field", name: { kind: "Name", value: "id" } }
|
|
42818
|
+
]
|
|
42819
|
+
}
|
|
42820
|
+
}
|
|
42821
|
+
]
|
|
42822
|
+
}
|
|
42823
|
+
}
|
|
42824
|
+
]
|
|
42825
|
+
};
|
|
42826
|
+
|
|
41906
42827
|
// src/controllers/schemas.ts
|
|
41907
|
-
var
|
|
42828
|
+
var import_graphql = require("graphql");
|
|
41908
42829
|
var SchemaController = class {
|
|
41909
42830
|
constructor(context) {
|
|
41910
42831
|
this.context = context;
|
|
@@ -42006,30 +42927,14 @@ var SchemaController = class {
|
|
|
42006
42927
|
account: this.context.walletClient.account || userAddress,
|
|
42007
42928
|
chain: this.context.walletClient.chain || null
|
|
42008
42929
|
});
|
|
42009
|
-
const
|
|
42010
|
-
|
|
42011
|
-
|
|
42012
|
-
|
|
42013
|
-
// 30 seconds timeout
|
|
42014
|
-
}
|
|
42930
|
+
const txHandle = new TransactionHandle(
|
|
42931
|
+
this.context,
|
|
42932
|
+
txHash,
|
|
42933
|
+
"addSchema"
|
|
42015
42934
|
);
|
|
42016
|
-
|
|
42017
|
-
for (const log of receipt.logs) {
|
|
42018
|
-
try {
|
|
42019
|
-
const decoded = (0, import_viem5.decodeEventLog)({
|
|
42020
|
-
abi: dataRefinerRegistryAbi,
|
|
42021
|
-
data: log.data,
|
|
42022
|
-
topics: log.topics
|
|
42023
|
-
});
|
|
42024
|
-
if (decoded.eventName === "SchemaAdded") {
|
|
42025
|
-
schemaId = Number(decoded.args.schemaId);
|
|
42026
|
-
break;
|
|
42027
|
-
}
|
|
42028
|
-
} catch {
|
|
42029
|
-
}
|
|
42030
|
-
}
|
|
42935
|
+
const result = await txHandle.waitForEvents();
|
|
42031
42936
|
return {
|
|
42032
|
-
schemaId,
|
|
42937
|
+
schemaId: Number(result.schemaId),
|
|
42033
42938
|
definitionUrl: uploadResult.url,
|
|
42034
42939
|
transactionHash: txHash
|
|
42035
42940
|
};
|
|
@@ -42046,15 +42951,30 @@ var SchemaController = class {
|
|
|
42046
42951
|
* Retrieves a schema by its ID.
|
|
42047
42952
|
*
|
|
42048
42953
|
* @param schemaId - The ID of the schema to retrieve
|
|
42954
|
+
* @param options - Optional parameters
|
|
42955
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
42049
42956
|
* @returns Promise resolving to the schema object
|
|
42050
42957
|
* @throws {Error} When the schema is not found or chain is unavailable
|
|
42051
42958
|
* @example
|
|
42052
42959
|
* ```typescript
|
|
42053
42960
|
* const schema = await vana.schemas.get(1);
|
|
42054
42961
|
* console.log(`Schema: ${schema.name} (${schema.type})`);
|
|
42962
|
+
*
|
|
42963
|
+
* // With custom subgraph
|
|
42964
|
+
* const schema = await vana.schemas.get(1, {
|
|
42965
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
42966
|
+
* });
|
|
42055
42967
|
* ```
|
|
42056
42968
|
*/
|
|
42057
|
-
async get(schemaId) {
|
|
42969
|
+
async get(schemaId, options = {}) {
|
|
42970
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
42971
|
+
if (subgraphUrl) {
|
|
42972
|
+
try {
|
|
42973
|
+
return await this._getSchemaViaSubgraph({ schemaId, subgraphUrl });
|
|
42974
|
+
} catch (error) {
|
|
42975
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
42976
|
+
}
|
|
42977
|
+
}
|
|
42058
42978
|
try {
|
|
42059
42979
|
return await fetchSchemaFromChain(this.context, schemaId);
|
|
42060
42980
|
} catch (error) {
|
|
@@ -42066,15 +42986,30 @@ var SchemaController = class {
|
|
|
42066
42986
|
/**
|
|
42067
42987
|
* Gets the total number of schemas registered on the network.
|
|
42068
42988
|
*
|
|
42989
|
+
* @param options - Optional parameters
|
|
42990
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
42069
42991
|
* @returns Promise resolving to the total schema count
|
|
42070
42992
|
* @throws {Error} When the count cannot be retrieved
|
|
42071
42993
|
* @example
|
|
42072
42994
|
* ```typescript
|
|
42073
42995
|
* const count = await vana.schemas.count();
|
|
42074
42996
|
* console.log(`Total schemas: ${count}`);
|
|
42997
|
+
*
|
|
42998
|
+
* // With custom subgraph
|
|
42999
|
+
* const count = await vana.schemas.count({
|
|
43000
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
43001
|
+
* });
|
|
42075
43002
|
* ```
|
|
42076
43003
|
*/
|
|
42077
|
-
async count() {
|
|
43004
|
+
async count(options = {}) {
|
|
43005
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
43006
|
+
if (subgraphUrl) {
|
|
43007
|
+
try {
|
|
43008
|
+
return await this._countSchemasViaSubgraph({ subgraphUrl });
|
|
43009
|
+
} catch (error) {
|
|
43010
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
43011
|
+
}
|
|
43012
|
+
}
|
|
42078
43013
|
try {
|
|
42079
43014
|
return await fetchSchemaCountFromChain(this.context);
|
|
42080
43015
|
} catch (error) {
|
|
@@ -42089,6 +43024,7 @@ var SchemaController = class {
|
|
|
42089
43024
|
* @param options - Optional parameters for listing schemas
|
|
42090
43025
|
* @param options.limit - Maximum number of schemas to return
|
|
42091
43026
|
* @param options.offset - Number of schemas to skip
|
|
43027
|
+
* @param options.subgraphUrl - Custom subgraph URL to use instead of default
|
|
42092
43028
|
* @returns Promise resolving to an array of schemas
|
|
42093
43029
|
* @example
|
|
42094
43030
|
* ```typescript
|
|
@@ -42097,23 +43033,78 @@ var SchemaController = class {
|
|
|
42097
43033
|
*
|
|
42098
43034
|
* // Get schemas with pagination
|
|
42099
43035
|
* const schemas = await vana.schemas.list({ limit: 10, offset: 0 });
|
|
43036
|
+
*
|
|
43037
|
+
* // With custom subgraph
|
|
43038
|
+
* const schemas = await vana.schemas.list({
|
|
43039
|
+
* limit: 10,
|
|
43040
|
+
* offset: 0,
|
|
43041
|
+
* subgraphUrl: 'https://custom-subgraph.com/graphql'
|
|
43042
|
+
* });
|
|
42100
43043
|
* ```
|
|
42101
43044
|
*/
|
|
42102
43045
|
async list(options = {}) {
|
|
42103
43046
|
const { limit = 100, offset = 0 } = options;
|
|
43047
|
+
const subgraphUrl = options.subgraphUrl || this.context.subgraphUrl;
|
|
43048
|
+
if (subgraphUrl) {
|
|
43049
|
+
try {
|
|
43050
|
+
return await this._listSchemasViaSubgraph({
|
|
43051
|
+
limit,
|
|
43052
|
+
offset,
|
|
43053
|
+
subgraphUrl
|
|
43054
|
+
});
|
|
43055
|
+
} catch (error) {
|
|
43056
|
+
console.debug("Subgraph query failed, falling back to RPC:", error);
|
|
43057
|
+
}
|
|
43058
|
+
}
|
|
42104
43059
|
try {
|
|
42105
43060
|
const totalCount = await this.count();
|
|
42106
|
-
const schemas = [];
|
|
42107
43061
|
const start = offset;
|
|
42108
43062
|
const end = Math.min(start + limit, totalCount);
|
|
43063
|
+
if (end <= start) {
|
|
43064
|
+
return [];
|
|
43065
|
+
}
|
|
43066
|
+
const chainId = this.context.walletClient.chain?.id;
|
|
43067
|
+
if (!chainId) {
|
|
43068
|
+
throw new Error("Chain ID not available");
|
|
43069
|
+
}
|
|
43070
|
+
const dataRefinerRegistryAddress = getContractAddress(
|
|
43071
|
+
chainId,
|
|
43072
|
+
"DataRefinerRegistry"
|
|
43073
|
+
);
|
|
43074
|
+
const dataRefinerRegistryAbi = getAbi("DataRefinerRegistry");
|
|
43075
|
+
const schemaCalls = [];
|
|
42109
43076
|
for (let i = start; i < end; i++) {
|
|
42110
|
-
|
|
42111
|
-
|
|
42112
|
-
|
|
42113
|
-
|
|
42114
|
-
|
|
42115
|
-
|
|
43077
|
+
schemaCalls.push({
|
|
43078
|
+
address: dataRefinerRegistryAddress,
|
|
43079
|
+
abi: dataRefinerRegistryAbi,
|
|
43080
|
+
functionName: "schemas",
|
|
43081
|
+
args: [BigInt(i + 1)]
|
|
43082
|
+
// Schema IDs are 1-based
|
|
43083
|
+
});
|
|
42116
43084
|
}
|
|
43085
|
+
const schemaResults = await gasAwareMulticall(this.context.publicClient, {
|
|
43086
|
+
contracts: schemaCalls,
|
|
43087
|
+
allowFailure: true
|
|
43088
|
+
});
|
|
43089
|
+
const schemas = [];
|
|
43090
|
+
schemaResults.forEach((result, index) => {
|
|
43091
|
+
if (result.status === "success" && result.result) {
|
|
43092
|
+
const schemaId = start + index + 1;
|
|
43093
|
+
const schemaData = result.result;
|
|
43094
|
+
if (schemaData.name && schemaData.dialect && schemaData.definitionUrl) {
|
|
43095
|
+
schemas.push({
|
|
43096
|
+
id: schemaId,
|
|
43097
|
+
name: schemaData.name,
|
|
43098
|
+
dialect: schemaData.dialect,
|
|
43099
|
+
definitionUrl: schemaData.definitionUrl
|
|
43100
|
+
});
|
|
43101
|
+
} else {
|
|
43102
|
+
console.warn(`Incomplete schema data for ID ${schemaId}`);
|
|
43103
|
+
}
|
|
43104
|
+
} else {
|
|
43105
|
+
console.warn(`Failed to retrieve schema ${start + index + 1}`);
|
|
43106
|
+
}
|
|
43107
|
+
});
|
|
42117
43108
|
return schemas;
|
|
42118
43109
|
} catch (error) {
|
|
42119
43110
|
throw new Error(
|
|
@@ -42144,7 +43135,7 @@ var SchemaController = class {
|
|
|
42144
43135
|
address: dataRefinerRegistryAddress,
|
|
42145
43136
|
abi: dataRefinerRegistryAbi,
|
|
42146
43137
|
functionName: "addSchema",
|
|
42147
|
-
args: [params.name, params.
|
|
43138
|
+
args: [params.name, params.dialect, params.definitionUrl],
|
|
42148
43139
|
account: this.context.walletClient.account || userAddress,
|
|
42149
43140
|
chain: this.context.walletClient.chain || null
|
|
42150
43141
|
});
|
|
@@ -42159,6 +43150,119 @@ var SchemaController = class {
|
|
|
42159
43150
|
);
|
|
42160
43151
|
}
|
|
42161
43152
|
}
|
|
43153
|
+
/**
|
|
43154
|
+
* Internal method: Query schema via subgraph
|
|
43155
|
+
*
|
|
43156
|
+
* @param params - Query parameters
|
|
43157
|
+
* @param params.schemaId - The ID of the schema to retrieve
|
|
43158
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
43159
|
+
* @returns Promise resolving to the schema object
|
|
43160
|
+
* @private
|
|
43161
|
+
*/
|
|
43162
|
+
async _getSchemaViaSubgraph(params) {
|
|
43163
|
+
const { schemaId, subgraphUrl } = params;
|
|
43164
|
+
const response = await fetch(subgraphUrl, {
|
|
43165
|
+
method: "POST",
|
|
43166
|
+
headers: { "Content-Type": "application/json" },
|
|
43167
|
+
body: JSON.stringify({
|
|
43168
|
+
query: (0, import_graphql.print)(GetSchemaDocument),
|
|
43169
|
+
variables: { id: schemaId.toString() }
|
|
43170
|
+
})
|
|
43171
|
+
});
|
|
43172
|
+
if (!response.ok) {
|
|
43173
|
+
throw new Error(
|
|
43174
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
43175
|
+
);
|
|
43176
|
+
}
|
|
43177
|
+
const result = await response.json();
|
|
43178
|
+
if (result.errors) {
|
|
43179
|
+
throw new Error(
|
|
43180
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
43181
|
+
);
|
|
43182
|
+
}
|
|
43183
|
+
if (!result.data?.schema) {
|
|
43184
|
+
throw new Error(`Schema ${schemaId} not found in subgraph`);
|
|
43185
|
+
}
|
|
43186
|
+
const subgraphSchema = result.data.schema;
|
|
43187
|
+
return {
|
|
43188
|
+
id: parseInt(subgraphSchema.id),
|
|
43189
|
+
name: subgraphSchema.name,
|
|
43190
|
+
dialect: subgraphSchema.dialect,
|
|
43191
|
+
definitionUrl: subgraphSchema.definitionUrl
|
|
43192
|
+
};
|
|
43193
|
+
}
|
|
43194
|
+
/**
|
|
43195
|
+
* Internal method: List schemas via subgraph
|
|
43196
|
+
*
|
|
43197
|
+
* @param params - Query parameters
|
|
43198
|
+
* @param params.limit - Maximum number of schemas to return
|
|
43199
|
+
* @param params.offset - Number of schemas to skip
|
|
43200
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
43201
|
+
* @returns Promise resolving to an array of schemas
|
|
43202
|
+
* @private
|
|
43203
|
+
*/
|
|
43204
|
+
async _listSchemasViaSubgraph(params) {
|
|
43205
|
+
const { limit, offset, subgraphUrl } = params;
|
|
43206
|
+
const response = await fetch(subgraphUrl, {
|
|
43207
|
+
method: "POST",
|
|
43208
|
+
headers: { "Content-Type": "application/json" },
|
|
43209
|
+
body: JSON.stringify({
|
|
43210
|
+
query: (0, import_graphql.print)(ListSchemasDocument),
|
|
43211
|
+
variables: { first: limit, skip: offset }
|
|
43212
|
+
})
|
|
43213
|
+
});
|
|
43214
|
+
if (!response.ok) {
|
|
43215
|
+
throw new Error(
|
|
43216
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
43217
|
+
);
|
|
43218
|
+
}
|
|
43219
|
+
const result = await response.json();
|
|
43220
|
+
if (result.errors) {
|
|
43221
|
+
throw new Error(
|
|
43222
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
43223
|
+
);
|
|
43224
|
+
}
|
|
43225
|
+
if (!result.data?.schemas) {
|
|
43226
|
+
return [];
|
|
43227
|
+
}
|
|
43228
|
+
return result.data.schemas.map((schema) => ({
|
|
43229
|
+
id: parseInt(schema.id),
|
|
43230
|
+
name: schema.name,
|
|
43231
|
+
dialect: schema.dialect,
|
|
43232
|
+
definitionUrl: schema.definitionUrl
|
|
43233
|
+
}));
|
|
43234
|
+
}
|
|
43235
|
+
/**
|
|
43236
|
+
* Internal method: Count schemas via subgraph
|
|
43237
|
+
*
|
|
43238
|
+
* @param params - Query parameters
|
|
43239
|
+
* @param params.subgraphUrl - The subgraph URL to query
|
|
43240
|
+
* @returns Promise resolving to the total schema count
|
|
43241
|
+
* @private
|
|
43242
|
+
*/
|
|
43243
|
+
async _countSchemasViaSubgraph(params) {
|
|
43244
|
+
const { subgraphUrl } = params;
|
|
43245
|
+
const response = await fetch(subgraphUrl, {
|
|
43246
|
+
method: "POST",
|
|
43247
|
+
headers: { "Content-Type": "application/json" },
|
|
43248
|
+
body: JSON.stringify({
|
|
43249
|
+
query: (0, import_graphql.print)(CountSchemasDocument),
|
|
43250
|
+
variables: {}
|
|
43251
|
+
})
|
|
43252
|
+
});
|
|
43253
|
+
if (!response.ok) {
|
|
43254
|
+
throw new Error(
|
|
43255
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
43256
|
+
);
|
|
43257
|
+
}
|
|
43258
|
+
const result = await response.json();
|
|
43259
|
+
if (result.errors) {
|
|
43260
|
+
throw new Error(
|
|
43261
|
+
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
43262
|
+
);
|
|
43263
|
+
}
|
|
43264
|
+
return result.data?.schemas?.length || 0;
|
|
43265
|
+
}
|
|
42162
43266
|
/**
|
|
42163
43267
|
* Gets the user's wallet address.
|
|
42164
43268
|
*
|
|
@@ -42593,7 +43697,12 @@ var chains = {
|
|
|
42593
43697
|
};
|
|
42594
43698
|
|
|
42595
43699
|
// src/core/client.ts
|
|
42596
|
-
var
|
|
43700
|
+
var defaultFromBlocks = {
|
|
43701
|
+
14800: BigInt(732312),
|
|
43702
|
+
// Moksha Testnet - earliest contract deployment
|
|
43703
|
+
1480: BigInt(758584)
|
|
43704
|
+
// Vana Mainnet - earliest contract deployment
|
|
43705
|
+
};
|
|
42597
43706
|
var _client;
|
|
42598
43707
|
var createClient = (chainId = mokshaTestnet.id) => {
|
|
42599
43708
|
if (!_client || _client.chain?.id !== chainId) {
|
|
@@ -44238,7 +45347,7 @@ var vanaMainnet2 = {
|
|
|
44238
45347
|
url: "https://vanascan.io"
|
|
44239
45348
|
}
|
|
44240
45349
|
},
|
|
44241
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.
|
|
45350
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.7/gn"
|
|
44242
45351
|
};
|
|
44243
45352
|
var moksha = {
|
|
44244
45353
|
id: 14800,
|
|
@@ -44259,7 +45368,7 @@ var moksha = {
|
|
|
44259
45368
|
url: "https://moksha.vanascan.io"
|
|
44260
45369
|
}
|
|
44261
45370
|
},
|
|
44262
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.
|
|
45371
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.7/gn"
|
|
44263
45372
|
};
|
|
44264
45373
|
function getChainConfig(chainId) {
|
|
44265
45374
|
switch (chainId) {
|
|
@@ -45239,37 +46348,37 @@ async function handleRelayerRequest(sdk, payload) {
|
|
|
45239
46348
|
}
|
|
45240
46349
|
switch (typedData.primaryType) {
|
|
45241
46350
|
case "Permission":
|
|
45242
|
-
return
|
|
46351
|
+
return sdk.permissions.submitSignedGrant(
|
|
45243
46352
|
typedData,
|
|
45244
46353
|
signature
|
|
45245
46354
|
);
|
|
45246
46355
|
case "PermissionRevoke":
|
|
45247
|
-
return
|
|
46356
|
+
return sdk.permissions.submitSignedRevoke(
|
|
45248
46357
|
typedData,
|
|
45249
46358
|
signature
|
|
45250
46359
|
);
|
|
45251
46360
|
case "TrustServer":
|
|
45252
|
-
return
|
|
46361
|
+
return sdk.permissions.submitSignedTrustServer(
|
|
45253
46362
|
typedData,
|
|
45254
46363
|
signature
|
|
45255
46364
|
);
|
|
45256
46365
|
case "AddServer":
|
|
45257
|
-
return
|
|
46366
|
+
return sdk.permissions.submitSignedAddAndTrustServer(
|
|
45258
46367
|
typedData,
|
|
45259
46368
|
signature
|
|
45260
46369
|
);
|
|
45261
46370
|
case "UntrustServer":
|
|
45262
|
-
return
|
|
46371
|
+
return sdk.permissions.submitSignedUntrustServer(
|
|
45263
46372
|
typedData,
|
|
45264
46373
|
signature
|
|
45265
46374
|
);
|
|
45266
46375
|
case "RegisterGrantee":
|
|
45267
|
-
return
|
|
46376
|
+
return sdk.permissions.submitSignedRegisterGrantee(
|
|
45268
46377
|
typedData,
|
|
45269
46378
|
signature
|
|
45270
46379
|
);
|
|
45271
46380
|
case "ServerFilesAndPermission":
|
|
45272
|
-
return
|
|
46381
|
+
return sdk.permissions.submitSignedAddServerFilesAndPermissions(
|
|
45273
46382
|
typedData,
|
|
45274
46383
|
signature
|
|
45275
46384
|
);
|
|
@@ -45733,6 +46842,7 @@ var index_node_default = Vana;
|
|
|
45733
46842
|
SignatureError,
|
|
45734
46843
|
StorageError,
|
|
45735
46844
|
StorageManager,
|
|
46845
|
+
TransactionHandle,
|
|
45736
46846
|
UserRejectedRequestError,
|
|
45737
46847
|
Vana,
|
|
45738
46848
|
VanaCore,
|