@invisi-labs/sdk 1.1.2 → 1.1.3

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/dist/memory.cjs CHANGED
@@ -1035,6 +1035,7 @@ var MemoryAtomicRecords = class {
1035
1035
  };
1036
1036
 
1037
1037
  // src/session/operation-protocol.ts
1038
+ var import_core3 = require("@invisi-labs/core");
1038
1039
  var import_protocol2 = require("@invisi-labs/protocol");
1039
1040
  function requiresAuthorization(plan) {
1040
1041
  if (plan.kind === "sweep") {
@@ -1172,6 +1173,7 @@ async function witnessFor(protocol, plan, authorization) {
1172
1173
  }
1173
1174
  if (credit.draw) {
1174
1175
  return builder.drawCredit({
1176
+ timestamp: plan.preparedAt.timestamp,
1175
1177
  params: credit.draw,
1176
1178
  deliveries: credit.deliveries,
1177
1179
  inputs: credit.inputs,
@@ -1302,12 +1304,836 @@ function operationExpired(plan, now) {
1302
1304
  const credit = plan.credit;
1303
1305
  if (credit?.topUp && now >= credit.topUp.previousExpiry) return true;
1304
1306
  if (credit?.creation && now >= credit.creation.expiry) return true;
1305
- if (credit?.draw && credit.draw.expiries.some((expiry) => now >= expiry)) return true;
1307
+ if (credit?.draw) {
1308
+ if (credit.draw.expiries.some((expiry) => now >= expiry)) return true;
1309
+ const prepared = (0, import_core3.creditPeriods)(plan.preparedAt.timestamp), current2 = (0, import_core3.creditPeriods)(now);
1310
+ if (prepared.currentDay !== current2.currentDay || prepared.currentMonth !== current2.currentMonth)
1311
+ return true;
1312
+ }
1306
1313
  return false;
1307
1314
  }
1308
1315
 
1309
1316
  // src/data/gas-benchmarks.json
1310
1317
  var gas_benchmarks_default = [
1318
+ {
1319
+ formatVersion: 1,
1320
+ id: "protocol-42f2546-621cbef5f84a-prague-credit-real",
1321
+ deployment: {
1322
+ chainId: "31337",
1323
+ protocolAddress: "0xEeD9be753bccbCB21463C49f0c56cC0E48bEcf3c",
1324
+ runtimeCodeHash: "0x80228a2080d224b4481fc5df24fe8ce080d4536c663b13ec7829ecf0ef46abbd",
1325
+ tokenAddress: "0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf"
1326
+ },
1327
+ source: {
1328
+ protocolCommit: "42f2546b62312e4c11e21b8e6b2ff6f72187d6a6",
1329
+ measuredAt: "2026-10-29T10:56:24.758Z",
1330
+ chain: "Anvil 31337",
1331
+ hardfork: "prague",
1332
+ token: "MockERC20",
1333
+ verifier: "real",
1334
+ fingerprints: {
1335
+ protocolSourceSha256: "621cbef5f84a133ca96674a2dba39b21b5f9fbc022977d4d2ab296d9d6e685e0",
1336
+ dirtyDiffSha256: "eb2c41cca3802a47196181648397ec6f47fb2ba0efa8aa3800508d8d255fae3f",
1337
+ compiledArtifactsSha256: "c0e658d74fe49caeebf5ef9deadc1751d9e48add690f7e9ab478de7a00dab7e4",
1338
+ creditManifestSha256: "da819378af60471905cc902a43e464b58159e0c75bd46fb804ea9d34d8aa7ef6",
1339
+ userManifestSha256: "067b6c50e4bc4d9c19dd29f25352db88d189a5f49aed0ed603daa70760e699df",
1340
+ sdkSourceSha256: "37e1f82a447db741f46e1490b866ddf85718eab42c33d369cf5f5d2ec3a25c78"
1341
+ },
1342
+ toolchain: {
1343
+ solidity: "0.8.38",
1344
+ barretenberg: "6.0.0",
1345
+ noir: "1.0.0-rc.6",
1346
+ evmVersion: "prague",
1347
+ optimizerRuns: 200,
1348
+ anvil: "anvil Version: 1.8.6"
1349
+ },
1350
+ blockGasLimit: "500000000",
1351
+ runtimeContracts: {
1352
+ transact_user_slots14_direct_Verifier: {
1353
+ address: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
1354
+ runtimeCodeHash: "0xedab185b2b9fc7d98660db2cdc99fe30b9d1341dfe568172a1626e322d208f7e"
1355
+ },
1356
+ "transact_user_slots14-adapter": {
1357
+ address: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
1358
+ runtimeCodeHash: "0xe222cd9c142bc2b13e083e6fe66ea76c0e1e9a194715bfa57082b625c55d867f"
1359
+ },
1360
+ transact_user_slots56_direct_Verifier: {
1361
+ address: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
1362
+ runtimeCodeHash: "0x8913eb7060f38234aca199c4a1007892f68e703de48b588c436b24faaeb23a53"
1363
+ },
1364
+ "transact_user_slots56-adapter": {
1365
+ address: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
1366
+ runtimeCodeHash: "0x97c416d190da0b9b8111a5ee17367e8a702ba7884019bf724155ae629a783477"
1367
+ },
1368
+ transact_user_slots112_direct_Verifier: {
1369
+ address: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
1370
+ runtimeCodeHash: "0x501a4791ff0c0a96465ab5e0d42d0ce763bbbb7fd8aebe21929de4d460e1b42c"
1371
+ },
1372
+ "transact_user_slots112-adapter": {
1373
+ address: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
1374
+ runtimeCodeHash: "0xf22ed8ea34a4011650a41c1b9f664b5259ea5a8d66a82d706dab9611a38c109f"
1375
+ },
1376
+ transact_user_slots168_direct_Verifier: {
1377
+ address: "0x0165878A594ca255338adfa4d48449f69242Eb8F",
1378
+ runtimeCodeHash: "0xc22acdfa6f3e278ae46d194a1c50b905e4815fd7b61e39edb52334570670fdce"
1379
+ },
1380
+ "transact_user_slots168-adapter": {
1381
+ address: "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
1382
+ runtimeCodeHash: "0x05a318f54d93440a501b6fc6be88e4e76e89d72f1be8333553cb4a61f4f9a0d7"
1383
+ },
1384
+ transact_aggregate_14_4_Verifier: {
1385
+ address: "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
1386
+ runtimeCodeHash: "0x7a6f2bafe4c61a72a99a195e188f2f4a32900c0cc63cc132e33881d8199fd446"
1387
+ },
1388
+ "transact_aggregate_14_4-adapter": {
1389
+ address: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
1390
+ runtimeCodeHash: "0x15877da9940d5b8dd4868ffa92ded3b93d6092c3963ba9e18b50f1ea15d89898"
1391
+ },
1392
+ transact_aggregate_14_8_Verifier: {
1393
+ address: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
1394
+ runtimeCodeHash: "0x5667d16b39973813a499375f6885a3082d7bfcd6e3c0f3548d7de3131cd285f3"
1395
+ },
1396
+ "transact_aggregate_14_8-adapter": {
1397
+ address: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
1398
+ runtimeCodeHash: "0x9d1a93c78edf7e81b4b6da10ab209b3fb009ed8355594f670559a67842d88cfc"
1399
+ },
1400
+ transact_aggregate_14_12_Verifier: {
1401
+ address: "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
1402
+ runtimeCodeHash: "0xa4e67840a47182d4011d577981c2477bb4ab2bc36845bb136375f19f12c0800b"
1403
+ },
1404
+ "transact_aggregate_14_12-adapter": {
1405
+ address: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
1406
+ runtimeCodeHash: "0x96a6e170aafc0af9d46232ba00206d950bba85e65962d43501bafb6d7f9fe61d"
1407
+ },
1408
+ create_credit_direct_Verifier: {
1409
+ address: "0x9A676e781A523b5d0C0e43731313A708CB607508",
1410
+ runtimeCodeHash: "0xbdc6450bf9ba01001082f345b8bd21006a4f75274f32d026cf6e14270e6d56e6"
1411
+ },
1412
+ "create_credit-adapter": {
1413
+ address: "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
1414
+ runtimeCodeHash: "0x3a95a22b32aef18ce053a7110056bbfbf13bb0b07932a49765ebb136528a4707"
1415
+ },
1416
+ credit_draw_slots1_direct_Verifier: {
1417
+ address: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
1418
+ runtimeCodeHash: "0x47be80e72c3a22ea044638f6004de8c3a0264d5a0d17189c01153cdabfd7bab6"
1419
+ },
1420
+ "credit_draw_slots1-adapter": {
1421
+ address: "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
1422
+ runtimeCodeHash: "0x28f25aeb97659fb9253ae67f2ff284789710bc59e1ed077ffc7a07b800cbfcc1"
1423
+ },
1424
+ credit_draw_slots12_direct_Verifier: {
1425
+ address: "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
1426
+ runtimeCodeHash: "0x244d9ba22f5c736c2a5c42c466701e2a8ba7ae8108665133541026ea45d56e04"
1427
+ },
1428
+ "credit_draw_slots12-adapter": {
1429
+ address: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
1430
+ runtimeCodeHash: "0x60d48a35279d318a0621e5f59b293f44074463b8002ce180b7e6a31b995ac195"
1431
+ },
1432
+ credit_draw_slots50_direct_Verifier: {
1433
+ address: "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
1434
+ runtimeCodeHash: "0x2ad5eb64bcfae34ef04111dd8f9c1ffc5fc8aa6c1ad3a65d8da78233f3390660"
1435
+ },
1436
+ "credit_draw_slots50-adapter": {
1437
+ address: "0x59b670e9fA9D0A427751Af201D676719a970857b",
1438
+ runtimeCodeHash: "0x468966de20e5c71cf7b6f3cda7fa7a76b5d80dc5ddf82119f441ea6a7c6c1e70"
1439
+ },
1440
+ credit_draw_slots120_direct_Verifier: {
1441
+ address: "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
1442
+ runtimeCodeHash: "0x523b6d211618bbd33d708f8198b9f3daafc10e2fa7a6a857db5795ed748a24e4"
1443
+ },
1444
+ "credit_draw_slots120-adapter": {
1445
+ address: "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
1446
+ runtimeCodeHash: "0xa91d585ce6037e703efb914205bf193881fde4f470d2fc63b615699b56175239"
1447
+ },
1448
+ credit_cancel_direct_Verifier: {
1449
+ address: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
1450
+ runtimeCodeHash: "0x182e86861a73f712071e40a6b8497b80c58c383eaa799182e7a50e39196399fd"
1451
+ },
1452
+ "credit_cancel-adapter": {
1453
+ address: "0x4A679253410272dd5232B3Ff7cF5dbB88f295319",
1454
+ runtimeCodeHash: "0xea1f0f22445eed5a92c8d6990219059b7e241ad66c55a6d9ddef22a94a0f015f"
1455
+ },
1456
+ credit_top_up_direct_Verifier: {
1457
+ address: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
1458
+ runtimeCodeHash: "0xeeb42a2b6377ab305b713d1caf4ca96edb302c6d1e1007239e5c70091819c266"
1459
+ },
1460
+ "credit_top_up-adapter": {
1461
+ address: "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
1462
+ runtimeCodeHash: "0xbcf35a1d0e6c16dd01b09f944889aa5917d358d986fe399a0343d06bbdedaa61"
1463
+ },
1464
+ PrivateTransferVerifierRegistry: {
1465
+ address: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
1466
+ runtimeCodeHash: "0x678684af147cb42c872184b6e22c8439748139ae0c5885032941ab8832fcb142"
1467
+ },
1468
+ CrossTreeVerifierRegistry: {
1469
+ address: "0x67d269191c92Caf3cD7723F116c85e6E9bf55933",
1470
+ runtimeCodeHash: "0xa5ee16fc7ed9f982450e42a48365a93bfca784fa884adcb8695b557e921cb93b"
1471
+ },
1472
+ DualVerifierRouter: {
1473
+ address: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
1474
+ runtimeCodeHash: "0xcc094ed6f1bcc9270c597f62b817e4fc0a54770f373320133c2836e5b07ef2cc"
1475
+ },
1476
+ AtomicBatchOutputLib: {
1477
+ address: "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
1478
+ runtimeCodeHash: "0x7c138c13e40b3ad0fee3b319d6c1580a21855cb5ecdda92571d530509d9b7316"
1479
+ },
1480
+ FundingLib: {
1481
+ address: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
1482
+ runtimeCodeHash: "0x898d13d6ec4123df85f21ee0f98678dcd9f9b9a60134f88e35c1ef1aaa0a45f9"
1483
+ },
1484
+ PrivateTransferLib: {
1485
+ address: "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
1486
+ runtimeCodeHash: "0xfb18f2dd0a39af1b99ae35c25e2746cb5bc85c205e041db5f440671d84c82e5e"
1487
+ },
1488
+ CrossTreeTransferLib: {
1489
+ address: "0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9",
1490
+ runtimeCodeHash: "0x7b33a08f2feb9da462b951c95482cb2909796a85c0fde7cc9a6b65ff8b7ff253"
1491
+ },
1492
+ AggregateTransferLib: {
1493
+ address: "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
1494
+ runtimeCodeHash: "0xb3b4bd3a428f5c35712a57180f07b2249774d399ca87d4494929148ea26c5b99"
1495
+ },
1496
+ CreateCreditLib: {
1497
+ address: "0x851356ae760d987E095750cCeb3bC6014560891C",
1498
+ runtimeCodeHash: "0xe37a4b7c129c4fba5615d25ed8b7e898e64a306c68f7e599ade911db98fe881c"
1499
+ },
1500
+ CreditLifecycleLib: {
1501
+ address: "0xf5059a5D33d5853360D16C683c16e67980206f36",
1502
+ runtimeCodeHash: "0xf87a2227680efa7070071516587793e2e847c172b83261b8983c826f8a8c79bb"
1503
+ },
1504
+ ShieldLib: {
1505
+ address: "0x95401dc811bb5740090279Ba06cfA8fcF6113778",
1506
+ runtimeCodeHash: "0x371e57d8d324e44445a4ec30303b89a8bc98bbdbd03aeaa80faf0f821a65451d"
1507
+ },
1508
+ InvisiFactory: {
1509
+ address: "0x998abeb3E57409262aE5b751f60747921B33613E",
1510
+ runtimeCodeHash: "0xc56e5a0b71f4a1f63576a6663efb62b17c0d7520b6885a8d3483a356e12edf9b"
1511
+ },
1512
+ InvisiAddressRegistry: {
1513
+ address: "0x70e0bA845a1A0F2DA3359C97E0285013525FFC49",
1514
+ runtimeCodeHash: "0x007da3f4e888366ba0eed52cd511c4a369359291387ad19ca37e89eb395fce30"
1515
+ },
1516
+ InvisiProtocol: {
1517
+ address: "0xEeD9be753bccbCB21463C49f0c56cC0E48bEcf3c",
1518
+ runtimeCodeHash: "0x80228a2080d224b4481fc5df24fe8ce080d4536c663b13ec7829ecf0ef46abbd"
1519
+ },
1520
+ MockERC20: {
1521
+ address: "0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf",
1522
+ runtimeCodeHash: "0xf7f676b5c54f6e94f82f0de65a0117468a0d915e8a79d150e74f76bd6d7f708b"
1523
+ }
1524
+ },
1525
+ assumptions: [
1526
+ "normal CREATE/Factory deployment and fresh registry; EIP170/EIP3860 unchanged; no code/storage injection",
1527
+ "Solidity0.8.38 optimizer200 Prague; pinned BB6.0.0 real verifiers; every native proof independently verified",
1528
+ "one physical source tree and 123 existing leaves shared by every sample; top-up has two authenticated source groups; no rollover or screener",
1529
+ "funding/approvals/121 genuine Credit seeds/usage-seed draw/payout reset excluded from business gas",
1530
+ "each round restores identical token balances, exact caller allowance100, note cursor, nullifiers and baseline; spender payout starts zero",
1531
+ "complete receipt.gasUsed is measured, including verifier/calldata/logging/output insertion; memo0",
1532
+ "Prague local block gas limit500000000; measured transactions may be unmineable under lower network transaction/block limits",
1533
+ "observed three-sample ranges are neither a confidence interval nor a recommended transaction gas limit"
1534
+ ]
1535
+ },
1536
+ measurements: [
1537
+ {
1538
+ id: "create-credit-caller-0x0",
1539
+ shape: {
1540
+ kind: "create-credit",
1541
+ target: "evm",
1542
+ capacity: 10,
1543
+ noteInputs: 0,
1544
+ noteOutputs: 0,
1545
+ sourceTrees: 0,
1546
+ creditInputs: 0,
1547
+ creditOutputs: 1,
1548
+ creditRemainders: 0,
1549
+ funding: "caller",
1550
+ permit: false,
1551
+ deliveryBytes: 1132
1552
+ },
1553
+ circuit: {
1554
+ circuitName: "create_credit",
1555
+ target: "evm",
1556
+ artifactSha256: "3ed6cfdee4f5fd840f023580f76c208768777fea79737f2511377e5c55be0230",
1557
+ vkSha256: "56f663c6053be0d158a271022d200c732597efd3a2e0be48fe94549d0b1795e0"
1558
+ },
1559
+ samples: [
1560
+ {
1561
+ gasUsed: "1574696",
1562
+ transactionHash: "0x76112c532a1b5f24ad84fb83f91789ba4acd15ed9473ec9a0267cd5fe605448d",
1563
+ blockNumber: "172",
1564
+ blockHash: "0x0d91421e94947132a19f38ffdd76932c2d85add201de3d9189325ed3568125a7",
1565
+ calldataBytes: 11780
1566
+ },
1567
+ {
1568
+ gasUsed: "1574576",
1569
+ transactionHash: "0x545f72d9d207329bfc69ef0d1e96470c614924d5e463d974cc001712bf619fd8",
1570
+ blockNumber: "172",
1571
+ blockHash: "0x2053f97a2b2f3cf66e14da0ab9c1d7bd462d2d4f3ef2b13021aefcddedb71cf8",
1572
+ calldataBytes: 11780
1573
+ },
1574
+ {
1575
+ gasUsed: "1574612",
1576
+ transactionHash: "0x880ec0c666068d0756fba39947dc5b211aeebb31f41bd1e1e54856b090f65d34",
1577
+ blockNumber: "172",
1578
+ blockHash: "0xbb86ed21379a917e9688a3c90364ae8fbe1ba633ac068360e0a82bf4d3113b6d",
1579
+ calldataBytes: 11780
1580
+ }
1581
+ ]
1582
+ },
1583
+ {
1584
+ id: "create-credit-1x1",
1585
+ shape: {
1586
+ kind: "create-credit",
1587
+ target: "evm",
1588
+ capacity: 10,
1589
+ noteInputs: 1,
1590
+ noteOutputs: 1,
1591
+ sourceTrees: 1,
1592
+ creditInputs: 0,
1593
+ creditOutputs: 1,
1594
+ creditRemainders: 0,
1595
+ funding: "none",
1596
+ permit: false,
1597
+ deliveryBytes: 1360
1598
+ },
1599
+ circuit: {
1600
+ circuitName: "create_credit",
1601
+ target: "evm",
1602
+ artifactSha256: "3ed6cfdee4f5fd840f023580f76c208768777fea79737f2511377e5c55be0230",
1603
+ vkSha256: "56f663c6053be0d158a271022d200c732597efd3a2e0be48fe94549d0b1795e0"
1604
+ },
1605
+ samples: [
1606
+ {
1607
+ gasUsed: "1671641",
1608
+ transactionHash: "0x24ca3f03681aeb188b48989d5eaf7dd264a8c32e828acd34ff1b44be74f17ea6",
1609
+ blockNumber: "172",
1610
+ blockHash: "0xcdac07aa5d3ec187874dc1fc9be65503235289c7036ebe455feaf5161db42bb5",
1611
+ calldataBytes: 12132
1612
+ },
1613
+ {
1614
+ gasUsed: "1671509",
1615
+ transactionHash: "0x31a7f69ab02effa5fdd2e02bd02fb7e715a54786813261113fd7c07a0d3ef549",
1616
+ blockNumber: "172",
1617
+ blockHash: "0xc78ca874aa22cc6b8ea19e12a2806ba448a0f844345450d3fedc9841ea71c3a8",
1618
+ calldataBytes: 12132
1619
+ },
1620
+ {
1621
+ gasUsed: "1671485",
1622
+ transactionHash: "0xc5a30116885dcac8b3631c15847544cfeb91c46bde44c3765ac0ce42e3259157",
1623
+ blockNumber: "172",
1624
+ blockHash: "0x4a2c90ff972da4d37408567062779762efbb5790d4784d03842ee2c926c8c894",
1625
+ calldataBytes: 12132
1626
+ }
1627
+ ]
1628
+ },
1629
+ {
1630
+ id: "draw-credit-1-partial",
1631
+ shape: {
1632
+ kind: "draw-credit",
1633
+ target: "evm",
1634
+ capacity: 1,
1635
+ noteInputs: 0,
1636
+ noteOutputs: 0,
1637
+ sourceTrees: 1,
1638
+ creditInputs: 1,
1639
+ creditOutputs: 1,
1640
+ creditRemainders: 1,
1641
+ funding: "none",
1642
+ permit: false,
1643
+ deliveryBytes: 1132
1644
+ },
1645
+ circuit: {
1646
+ circuitName: "credit_draw_slots1",
1647
+ target: "evm",
1648
+ artifactSha256: "4542b227e0552b45c302f1dace21cadeba4962c96244e021472f1f7531cff8d1",
1649
+ vkSha256: "43c051a2bedf9454c12e70b10156361e414944823ba23e80662c16c7ced0a2ce"
1650
+ },
1651
+ samples: [
1652
+ {
1653
+ gasUsed: "1588303",
1654
+ transactionHash: "0x85c5180692470aa952aa13eb29ca0404d4f5b5192cb31475f90d03d78864895e",
1655
+ blockNumber: "172",
1656
+ blockHash: "0xfe4876c0a2ebf05385a46562bca693b6df80da731fd9651117593916015dc38c",
1657
+ calldataBytes: 11588
1658
+ },
1659
+ {
1660
+ gasUsed: "1588303",
1661
+ transactionHash: "0x61684313840623187ca1205b4b07b43a08038448524ee1a028c7e14050032682",
1662
+ blockNumber: "172",
1663
+ blockHash: "0x9726d31c10e6516e38e3f63c84fc4b9a8a161486d35e0d8d07e6829261a88fe7",
1664
+ calldataBytes: 11588
1665
+ },
1666
+ {
1667
+ gasUsed: "1588255",
1668
+ transactionHash: "0x0aa052fb8e356cc81dd73bcdae72f760937cd2e56bd4a3e8eb5878208b4f7596",
1669
+ blockNumber: "172",
1670
+ blockHash: "0x2c958cfba0627e18cd5cb47001b278628c305071929596e3335d770b92c1dc16",
1671
+ calldataBytes: 11588
1672
+ }
1673
+ ]
1674
+ },
1675
+ {
1676
+ id: "draw-credit-1-full",
1677
+ shape: {
1678
+ kind: "draw-credit",
1679
+ target: "evm",
1680
+ capacity: 1,
1681
+ noteInputs: 0,
1682
+ noteOutputs: 0,
1683
+ sourceTrees: 1,
1684
+ creditInputs: 1,
1685
+ creditOutputs: 0,
1686
+ creditRemainders: 0,
1687
+ funding: "none",
1688
+ permit: false,
1689
+ deliveryBytes: 0
1690
+ },
1691
+ circuit: {
1692
+ circuitName: "credit_draw_slots1",
1693
+ target: "evm",
1694
+ artifactSha256: "4542b227e0552b45c302f1dace21cadeba4962c96244e021472f1f7531cff8d1",
1695
+ vkSha256: "43c051a2bedf9454c12e70b10156361e414944823ba23e80662c16c7ced0a2ce"
1696
+ },
1697
+ samples: [
1698
+ {
1699
+ gasUsed: "1042812",
1700
+ transactionHash: "0xb5d55729d975abdc92ca44c0b72e44a0d5841da8b23dc11b5bd31f46d88a341a",
1701
+ blockNumber: "172",
1702
+ blockHash: "0x8a6ddbe2f1630e1956485cac7984fb9cdc4fbb26b10522e158b38e2970ee4f3b",
1703
+ calldataBytes: 10372
1704
+ },
1705
+ {
1706
+ gasUsed: "1042824",
1707
+ transactionHash: "0xf64f3186fbf94fcbd9fb12426c714b4a8425599e1a7e5677866fae3d6873b7ae",
1708
+ blockNumber: "172",
1709
+ blockHash: "0xd630c44d8ce96234ec836dd2178caac2a6d0bc2df5cf37df1534eb8896be48d3",
1710
+ calldataBytes: 10372
1711
+ },
1712
+ {
1713
+ gasUsed: "1042884",
1714
+ transactionHash: "0xdf634e809b87603a62292ef046fa5e84715561fa76ef121c768303dd779568f1",
1715
+ blockNumber: "172",
1716
+ blockHash: "0x09cad4a799360bdf825c3ad70fe374b7fe2df802f8ee37ccb7f26ffc49aa2a3a",
1717
+ calldataBytes: 10372
1718
+ }
1719
+ ]
1720
+ },
1721
+ {
1722
+ id: "draw-credit-12-partial",
1723
+ shape: {
1724
+ kind: "draw-credit",
1725
+ target: "evm",
1726
+ capacity: 12,
1727
+ noteInputs: 0,
1728
+ noteOutputs: 0,
1729
+ sourceTrees: 1,
1730
+ creditInputs: 12,
1731
+ creditOutputs: 12,
1732
+ creditRemainders: 12,
1733
+ funding: "none",
1734
+ permit: false,
1735
+ deliveryBytes: 13584
1736
+ },
1737
+ circuit: {
1738
+ circuitName: "credit_draw_slots12",
1739
+ target: "evm",
1740
+ artifactSha256: "dd72b0867fc3be7cd90de263bd2d0892075cb18eb4f6dd671b13111710f10369",
1741
+ vkSha256: "5e31d771e6294993736078596d9c69f21fe7595eda50e3cce6d7406b65cf1443"
1742
+ },
1743
+ samples: [
1744
+ {
1745
+ gasUsed: "3102895",
1746
+ transactionHash: "0x699ba81f296f4af397a8dfaf96adf14d00d0f7dd69c0b09608641fc9b99fc28f",
1747
+ blockNumber: "172",
1748
+ blockHash: "0x8d318f563f5563fa5c213617481089f75aab3a6e9d14818db107ac20a8c20ffb",
1749
+ calldataBytes: 30276
1750
+ },
1751
+ {
1752
+ gasUsed: "3102871",
1753
+ transactionHash: "0xddfc1c6c505f6c54f4d9aabc96a02eb6b606182e8ad708a578eacd274d885dee",
1754
+ blockNumber: "172",
1755
+ blockHash: "0xcc7738fe329a608241615dc43b7d16e075eb62be202ea8aaf4ae27a5278bf438",
1756
+ calldataBytes: 30276
1757
+ },
1758
+ {
1759
+ gasUsed: "3103171",
1760
+ transactionHash: "0x6efab6408d927e1877f1f6c33ecd285a128382f7d1dfe6e123927b035781c8aa",
1761
+ blockNumber: "172",
1762
+ blockHash: "0xcb4588df9ecdca0d353ccbd226e1d5d07f21e6dc93875e41cdd5f64568859f4d",
1763
+ calldataBytes: 30276
1764
+ }
1765
+ ]
1766
+ },
1767
+ {
1768
+ id: "draw-credit-12-full",
1769
+ shape: {
1770
+ kind: "draw-credit",
1771
+ target: "evm",
1772
+ capacity: 12,
1773
+ noteInputs: 0,
1774
+ noteOutputs: 0,
1775
+ sourceTrees: 1,
1776
+ creditInputs: 12,
1777
+ creditOutputs: 0,
1778
+ creditRemainders: 0,
1779
+ funding: "none",
1780
+ permit: false,
1781
+ deliveryBytes: 0
1782
+ },
1783
+ circuit: {
1784
+ circuitName: "credit_draw_slots12",
1785
+ target: "evm",
1786
+ artifactSha256: "dd72b0867fc3be7cd90de263bd2d0892075cb18eb4f6dd671b13111710f10369",
1787
+ vkSha256: "5e31d771e6294993736078596d9c69f21fe7595eda50e3cce6d7406b65cf1443"
1788
+ },
1789
+ samples: [
1790
+ {
1791
+ gasUsed: "1536675",
1792
+ transactionHash: "0xc0d3eef8e6b0e90984d776a5e41bcdce1e0ca0bc6dc3a71616e4768e80c01546",
1793
+ blockNumber: "172",
1794
+ blockHash: "0x22dfac3d8e9913a6a1f2ff84faaece4ed59bfe1cb74e06a60131ff28cc6c2f9d",
1795
+ calldataBytes: 15684
1796
+ },
1797
+ {
1798
+ gasUsed: "1536675",
1799
+ transactionHash: "0x9879d86a1eaa550a6a6afaeeb0f5f07745d5dcd9caa07b660d7fb512911dc67e",
1800
+ blockNumber: "172",
1801
+ blockHash: "0xf88ba9f1b7a0c627338a61bbabe1c650bdfcd7fa1c56433d6853f492135b753d",
1802
+ calldataBytes: 15684
1803
+ },
1804
+ {
1805
+ gasUsed: "1536711",
1806
+ transactionHash: "0xbd8f75a021a8ce8dc1900bd2d84d723acc6a64018844050a5aa2f8712cf7fd6b",
1807
+ blockNumber: "172",
1808
+ blockHash: "0xa55b539c2ea4e10ce9a9ee8e6de9cf1daa97263b51f32cfef8342c100b663b0f",
1809
+ calldataBytes: 15684
1810
+ }
1811
+ ]
1812
+ },
1813
+ {
1814
+ id: "draw-credit-50-partial",
1815
+ shape: {
1816
+ kind: "draw-credit",
1817
+ target: "evm",
1818
+ capacity: 50,
1819
+ noteInputs: 0,
1820
+ noteOutputs: 0,
1821
+ sourceTrees: 1,
1822
+ creditInputs: 50,
1823
+ creditOutputs: 50,
1824
+ creditRemainders: 50,
1825
+ funding: "none",
1826
+ permit: false,
1827
+ deliveryBytes: 56600
1828
+ },
1829
+ circuit: {
1830
+ circuitName: "credit_draw_slots50",
1831
+ target: "evm",
1832
+ artifactSha256: "09c7469866748b4c0c4bbf2b040844771948a170999f6dc7a38fe5c0ecda4054",
1833
+ vkSha256: "7b613225b6f32a077011d4196c356e836d22dcd116efe687fde53144fbd8db9f"
1834
+ },
1835
+ samples: [
1836
+ {
1837
+ gasUsed: "8015473",
1838
+ transactionHash: "0x5dcc0fa08abaf5212424ac6f3e2f3bb8a0bd333f90ef6e421f8d3fe370ca1acf",
1839
+ blockNumber: "172",
1840
+ blockHash: "0x3197c523dece3492226c5021f974e7c02db2e686265943d03a5550c6cb96a12e",
1841
+ calldataBytes: 94276
1842
+ },
1843
+ {
1844
+ gasUsed: "8015449",
1845
+ transactionHash: "0x6a55f88551a45b3e118cde0607cfff1ef0b6ab15ad9472e838412d9ce714b42a",
1846
+ blockNumber: "172",
1847
+ blockHash: "0xea82c8962d45db8361bd67ed326806f21c511bd51550adc453d0c3e5cab3a7ae",
1848
+ calldataBytes: 94276
1849
+ },
1850
+ {
1851
+ gasUsed: "8015149",
1852
+ transactionHash: "0x2cc8d474a92abe91f8025109a70cf1f9f081dbec43aa4a475ab9f33222cfc76b",
1853
+ blockNumber: "172",
1854
+ blockHash: "0x4398f419da699ccca33867852d4975b5c461a40bb01cd5241a0e6dcacaeb78b3",
1855
+ calldataBytes: 94276
1856
+ }
1857
+ ]
1858
+ },
1859
+ {
1860
+ id: "draw-credit-50-full",
1861
+ shape: {
1862
+ kind: "draw-credit",
1863
+ target: "evm",
1864
+ capacity: 50,
1865
+ noteInputs: 0,
1866
+ noteOutputs: 0,
1867
+ sourceTrees: 1,
1868
+ creditInputs: 50,
1869
+ creditOutputs: 0,
1870
+ creditRemainders: 0,
1871
+ funding: "none",
1872
+ permit: false,
1873
+ deliveryBytes: 0
1874
+ },
1875
+ circuit: {
1876
+ circuitName: "credit_draw_slots50",
1877
+ target: "evm",
1878
+ artifactSha256: "09c7469866748b4c0c4bbf2b040844771948a170999f6dc7a38fe5c0ecda4054",
1879
+ vkSha256: "7b613225b6f32a077011d4196c356e836d22dcd116efe687fde53144fbd8db9f"
1880
+ },
1881
+ samples: [
1882
+ {
1883
+ gasUsed: "3216708",
1884
+ transactionHash: "0x16933368d26ea1d7fbe69027c700671df832ad308944eeff42e7c2da40297b06",
1885
+ blockNumber: "172",
1886
+ blockHash: "0x0739a6f4188b8bdeae7bd5460960086d04adfea993d07d65b2b3630ad01b8cab",
1887
+ calldataBytes: 33476
1888
+ },
1889
+ {
1890
+ gasUsed: "3216840",
1891
+ transactionHash: "0x45dc15a62b1661f54e167cf13b9693770370c926a8a7af959da7354e9bb4aa6e",
1892
+ blockNumber: "172",
1893
+ blockHash: "0xf2e294db9af3b11814fed1dec358b8370ea28a99189211f883c9b0012349d677",
1894
+ calldataBytes: 33476
1895
+ },
1896
+ {
1897
+ gasUsed: "3216744",
1898
+ transactionHash: "0x2c827753026ea421497534a01bcc2adaca866a7612f570dad3fcf18c660f8590",
1899
+ blockNumber: "172",
1900
+ blockHash: "0x3ccd465528ff22e6d1955670220df3565899a16dd683f71c83c9810f2df420b4",
1901
+ calldataBytes: 33476
1902
+ }
1903
+ ]
1904
+ },
1905
+ {
1906
+ id: "draw-credit-120-partial",
1907
+ shape: {
1908
+ kind: "draw-credit",
1909
+ target: "evm",
1910
+ capacity: 120,
1911
+ noteInputs: 0,
1912
+ noteOutputs: 0,
1913
+ sourceTrees: 1,
1914
+ creditInputs: 120,
1915
+ creditOutputs: 120,
1916
+ creditRemainders: 120,
1917
+ funding: "none",
1918
+ permit: false,
1919
+ deliveryBytes: 135840
1920
+ },
1921
+ circuit: {
1922
+ circuitName: "credit_draw_slots120",
1923
+ target: "evm",
1924
+ artifactSha256: "6ccd0366a669c50fd5da875c3eae194fe8aa4c36d35a5f9ebfd64636ea599b48",
1925
+ vkSha256: "d715848afc5c1ecdfcef5ed5026865abef5040a3bc232fd65330a5ffee8475fb"
1926
+ },
1927
+ samples: [
1928
+ {
1929
+ gasUsed: "17458512",
1930
+ transactionHash: "0x84dd6bda5f3172a53e899051fd226dc5869edb796bd513a33e7f224bed13f4ae",
1931
+ blockNumber: "172",
1932
+ blockHash: "0xfca82de1e112b92319185d8c3f0115e0aa339d0247ea65970eb0d37ba958b08e",
1933
+ calldataBytes: 211140
1934
+ },
1935
+ {
1936
+ gasUsed: "17458224",
1937
+ transactionHash: "0xae26838942cf8b5499d43cb5e74681ae87aec77890a8eabddd692ff83830e013",
1938
+ blockNumber: "172",
1939
+ blockHash: "0x3e513447e0cfdbb682a95b7a719b0d300ec46b0ee22b518eaae7fb082f6436e7",
1940
+ calldataBytes: 211140
1941
+ },
1942
+ {
1943
+ gasUsed: "17458524",
1944
+ transactionHash: "0xeaa07e77fe958f4317e71b07ddb876482ae9c5172fd6d6cefaacc551dbbda7d5",
1945
+ blockNumber: "172",
1946
+ blockHash: "0x12b34c1fd2e15480276052842157c2a6355acdd43d7bd01ae7511c3f39e0ecfc",
1947
+ calldataBytes: 211140
1948
+ }
1949
+ ]
1950
+ },
1951
+ {
1952
+ id: "draw-credit-120-full",
1953
+ shape: {
1954
+ kind: "draw-credit",
1955
+ target: "evm",
1956
+ capacity: 120,
1957
+ noteInputs: 0,
1958
+ noteOutputs: 0,
1959
+ sourceTrees: 1,
1960
+ creditInputs: 120,
1961
+ creditOutputs: 0,
1962
+ creditRemainders: 0,
1963
+ funding: "none",
1964
+ permit: false,
1965
+ deliveryBytes: 0
1966
+ },
1967
+ circuit: {
1968
+ circuitName: "credit_draw_slots120",
1969
+ target: "evm",
1970
+ artifactSha256: "6ccd0366a669c50fd5da875c3eae194fe8aa4c36d35a5f9ebfd64636ea599b48",
1971
+ vkSha256: "d715848afc5c1ecdfcef5ed5026865abef5040a3bc232fd65330a5ffee8475fb"
1972
+ },
1973
+ samples: [
1974
+ {
1975
+ gasUsed: "6289576",
1976
+ transactionHash: "0xbf11743f7edc5ed5ff334efc5e35634f45e48e4940d33ddd9c87d8fe444dafc5",
1977
+ blockNumber: "172",
1978
+ blockHash: "0x774de17971107b73cab2cd20f26b60665f55a37b0cc1147166babf16743e34d5",
1979
+ calldataBytes: 65220
1980
+ },
1981
+ {
1982
+ gasUsed: "6289768",
1983
+ transactionHash: "0x651bb13e0645ee8a08657db627f1072f5e964ddaff44f70f829440ed68488dea",
1984
+ blockNumber: "172",
1985
+ blockHash: "0xa9795828565fb0ce65bda295073106b8bbdc110bb8317d269839d3db3e312d5b",
1986
+ calldataBytes: 65220
1987
+ },
1988
+ {
1989
+ gasUsed: "6289720",
1990
+ transactionHash: "0x2a859d381cb4b50830971b1ffc9789b11569fc96147e130dae6fecd141f5ceb0",
1991
+ blockNumber: "172",
1992
+ blockHash: "0x7d990830157bfeff8e5cbe580e9effe97faa7676c9957ce32891b76c83961430",
1993
+ calldataBytes: 65220
1994
+ }
1995
+ ]
1996
+ },
1997
+ {
1998
+ id: "top-up-credit-1x1-unchanged-limits",
1999
+ shape: {
2000
+ kind: "top-up-credit",
2001
+ target: "evm",
2002
+ capacity: 10,
2003
+ noteInputs: 1,
2004
+ noteOutputs: 1,
2005
+ sourceTrees: 2,
2006
+ creditInputs: 1,
2007
+ creditOutputs: 1,
2008
+ creditRemainders: 0,
2009
+ funding: "none",
2010
+ permit: false,
2011
+ deliveryBytes: 1360
2012
+ },
2013
+ circuit: {
2014
+ circuitName: "credit_top_up",
2015
+ target: "evm",
2016
+ artifactSha256: "2ffebd5753ec1b0c050204d4f97498765fe61ea01a793a9b2466c2f97536345c",
2017
+ vkSha256: "40b02a9d2e7eb7b49daaac4b7760328537b7982fd5a225cc065bb74cd5ef44b3"
2018
+ },
2019
+ samples: [
2020
+ {
2021
+ gasUsed: "1711282",
2022
+ transactionHash: "0x74d45084bb07bacabbced09ee6ef69d8632a22a4493be783c326c47e929ba0ed",
2023
+ blockNumber: "172",
2024
+ blockHash: "0x3503643f7081b52ae20d4754a0e9b11f52034ae48059f5b5298546c2570fa091",
2025
+ calldataBytes: 12292
2026
+ },
2027
+ {
2028
+ gasUsed: "1711282",
2029
+ transactionHash: "0x4b5e2432d5571f6b56507b3ab995a8120560ba608959ff100f03b87873e72be6",
2030
+ blockNumber: "172",
2031
+ blockHash: "0xca15dc309371a5aa9c7bc5bf1d65c5b325c71528ce7856ba68a118114124fccc",
2032
+ calldataBytes: 12292
2033
+ },
2034
+ {
2035
+ gasUsed: "1711390",
2036
+ transactionHash: "0x304f3740b64c80dcc5c894fb30af59080d96a11e08371096ae695cbc46ef2c8b",
2037
+ blockNumber: "172",
2038
+ blockHash: "0x9671ed76d6b8e49a36ba229d3609289fcf70756f31277ac5fc0e3f08cd52304f",
2039
+ calldataBytes: 12292
2040
+ }
2041
+ ]
2042
+ },
2043
+ {
2044
+ id: "top-up-credit-1x1-changed-limits",
2045
+ shape: {
2046
+ kind: "top-up-credit",
2047
+ target: "evm",
2048
+ capacity: 10,
2049
+ noteInputs: 1,
2050
+ noteOutputs: 1,
2051
+ sourceTrees: 2,
2052
+ creditInputs: 1,
2053
+ creditOutputs: 1,
2054
+ creditRemainders: 0,
2055
+ funding: "none",
2056
+ permit: false,
2057
+ deliveryBytes: 1360
2058
+ },
2059
+ circuit: {
2060
+ circuitName: "credit_top_up",
2061
+ target: "evm",
2062
+ artifactSha256: "2ffebd5753ec1b0c050204d4f97498765fe61ea01a793a9b2466c2f97536345c",
2063
+ vkSha256: "40b02a9d2e7eb7b49daaac4b7760328537b7982fd5a225cc065bb74cd5ef44b3"
2064
+ },
2065
+ samples: [
2066
+ {
2067
+ gasUsed: "1711318",
2068
+ transactionHash: "0x65284df534b42631f8a592fb2a6efc16361a4cc122f1a8dd41418e7b950f48f1",
2069
+ blockNumber: "172",
2070
+ blockHash: "0xf198242a1edf5b133961568c9165648c829729e7bfbbf57a1e148551c971b87c",
2071
+ calldataBytes: 12292
2072
+ },
2073
+ {
2074
+ gasUsed: "1711438",
2075
+ transactionHash: "0xcee89a81e598974798365c4ebada806fb51196ee602334b0fffdbb25da0afe25",
2076
+ blockNumber: "172",
2077
+ blockHash: "0xb506a6fb54cc2f91b803211ed955aac0203fba93e2428f8f52ec0d413c90af09",
2078
+ calldataBytes: 12292
2079
+ },
2080
+ {
2081
+ gasUsed: "1711342",
2082
+ transactionHash: "0x957de5c79f365c9b0510b9e125a662317494aad50cb446edceef6f678d561cc7",
2083
+ blockNumber: "172",
2084
+ blockHash: "0xb1d5cffd6d6db58ade9d5e16d48b060b9ab2152415966dc809e7e70785472ab8",
2085
+ calldataBytes: 12292
2086
+ }
2087
+ ]
2088
+ },
2089
+ {
2090
+ id: "cancel-credit-1",
2091
+ shape: {
2092
+ kind: "cancel-credit",
2093
+ target: "evm",
2094
+ capacity: 1,
2095
+ noteInputs: 0,
2096
+ noteOutputs: 0,
2097
+ sourceTrees: 1,
2098
+ creditInputs: 1,
2099
+ creditOutputs: 0,
2100
+ creditRemainders: 0,
2101
+ funding: "none",
2102
+ permit: false,
2103
+ deliveryBytes: 0
2104
+ },
2105
+ circuit: {
2106
+ circuitName: "credit_cancel",
2107
+ target: "evm",
2108
+ artifactSha256: "b4459c2cf756d096e37291cf4d7cd129866b6d420b6d03c928f383b057112ccb",
2109
+ vkSha256: "fc8ad196ef15f3328afcc8f01d867a3ebefd15451c2813948442fab1923b73b2"
2110
+ },
2111
+ samples: [
2112
+ {
2113
+ gasUsed: "985543",
2114
+ transactionHash: "0x29ca63fbefcc5e92dbc86f67d6280993e567a5dd02ff3defd7f3251ce711865e",
2115
+ blockNumber: "172",
2116
+ blockHash: "0xecd7808fe9f7467af917069bd7a82ab0324e3cbab8dcad622b089d6e3eee9a58",
2117
+ calldataBytes: 9540
2118
+ },
2119
+ {
2120
+ gasUsed: "985795",
2121
+ transactionHash: "0xaf8bca0769330f89b647363f99b752dbbe6fdbb8b1aae912224f6a3a59f40faa",
2122
+ blockNumber: "172",
2123
+ blockHash: "0x58e1358e02f189d57628fa7c504b87fb000fe60eb9f0a0c3c0e58dae876e64da",
2124
+ calldataBytes: 9540
2125
+ },
2126
+ {
2127
+ gasUsed: "985711",
2128
+ transactionHash: "0x2c911fd5a422f6f72f2a00b16872b7e46e182d39b8f5bfa9e3b2bf99d3155da7",
2129
+ blockNumber: "172",
2130
+ blockHash: "0x9da571cbe63f52232261ee1527d5ed97a9e90e374b4fcda97d04feb25114d18e",
2131
+ calldataBytes: 9540
2132
+ }
2133
+ ]
2134
+ }
2135
+ ]
2136
+ },
1311
2137
  {
1312
2138
  formatVersion: 1,
1313
2139
  id: "protocol-92ef274-osaka-real",
@@ -1732,190 +2558,6 @@ var gas_benchmarks_default = [
1732
2558
  calldataBytes: 10116
1733
2559
  }
1734
2560
  ]
1735
- },
1736
- {
1737
- id: "create-credit-1x1",
1738
- shape: {
1739
- kind: "create-credit",
1740
- target: "evm",
1741
- capacity: 10,
1742
- noteInputs: 1,
1743
- noteOutputs: 1,
1744
- sourceTrees: 1,
1745
- creditInputs: 0,
1746
- creditOutputs: 1,
1747
- creditRemainders: 0,
1748
- funding: "none",
1749
- permit: false,
1750
- deliveryBytes: 1162
1751
- },
1752
- circuit: {
1753
- circuitName: "create_credit",
1754
- target: "evm",
1755
- artifactSha256: "ab97cd5a036851a9748a5cfd8e6f9834e23090c8e95db4531aabfc37d3abb353",
1756
- vkSha256: "fac0e65b768a28750323cca851990598af936611125b6cfa3f5c16b04c7d084f"
1757
- },
1758
- samples: [
1759
- {
1760
- gasUsed: "1627325",
1761
- transactionHash: "0x7763d93a5b1e8797b5f4af2e1e5b1bb029a8b0f9f7b90bcc04f581947d826803",
1762
- blockNumber: "49",
1763
- blockHash: "0x93e51ae5e99c68dc642693d478e444330d8e26255ff5bb9aafc4a3f4e70d3a45",
1764
- calldataBytes: 11940
1765
- },
1766
- {
1767
- gasUsed: "1627385",
1768
- transactionHash: "0xe246d59cafa2a26dddf21c8385dd843be4d4596388ebe23e936df84e7f906635",
1769
- blockNumber: "49",
1770
- blockHash: "0x3c24b2d6ed2a998562d34b49e0517515742a9b39d59aec38a9ac6b22be1b694b",
1771
- calldataBytes: 11940
1772
- },
1773
- {
1774
- gasUsed: "1627157",
1775
- transactionHash: "0x2f7ed0b75435cc6a820d0cd90fd82d362f74787057413722b6eb3c6e37db87d3",
1776
- blockNumber: "49",
1777
- blockHash: "0x0a0301670b46017da772800c68bb941245ac1941c79fde9c85717632154e15ee",
1778
- calldataBytes: 11940
1779
- }
1780
- ]
1781
- },
1782
- {
1783
- id: "draw-credit-1-partial",
1784
- shape: {
1785
- kind: "draw-credit",
1786
- target: "evm",
1787
- capacity: 1,
1788
- noteInputs: 0,
1789
- noteOutputs: 0,
1790
- sourceTrees: 1,
1791
- creditInputs: 1,
1792
- creditOutputs: 1,
1793
- creditRemainders: 1,
1794
- funding: "none",
1795
- permit: false,
1796
- deliveryBytes: 936
1797
- },
1798
- circuit: {
1799
- circuitName: "credit_draw_slots1",
1800
- target: "evm",
1801
- artifactSha256: "f5e458790948f37a61a833fad52cf2cc3b26a59515d271de32e0caaa4e229eb5",
1802
- vkSha256: "613699a440f50a0937e4c57e5152b5fdea42c31b10157d6b93226fef313df553"
1803
- },
1804
- samples: [
1805
- {
1806
- gasUsed: "1581294",
1807
- transactionHash: "0xd438e22b0fa07a657279f182537e4996f1936f0881d5b7d637845f8ca2808aab",
1808
- blockNumber: "49",
1809
- blockHash: "0x9e384a3054530b1ff237a639bca1a559afb2b73b30e21c262aac85ebf480fc9b",
1810
- calldataBytes: 11396
1811
- },
1812
- {
1813
- gasUsed: "1581402",
1814
- transactionHash: "0xa70ac3e7284b6e98f8591a6ba88e4ddfb23ecbd05343641d0532f34920e10b56",
1815
- blockNumber: "49",
1816
- blockHash: "0x37c5eb34ce96a841e96c36103a7ab65c1a3e08603dc9843efb0c0752c069f1d4",
1817
- calldataBytes: 11396
1818
- },
1819
- {
1820
- gasUsed: "1581174",
1821
- transactionHash: "0xd062494979d0bc0e284ccb070f87b48f3e8e5befb6001f15a006dd2a4a72ca24",
1822
- blockNumber: "49",
1823
- blockHash: "0x12840d920f14163b2d29491f28cee616e1bb9fd9514a4debe10ae35256345fc1",
1824
- calldataBytes: 11396
1825
- }
1826
- ]
1827
- },
1828
- {
1829
- id: "top-up-credit-1x1",
1830
- shape: {
1831
- kind: "top-up-credit",
1832
- target: "evm",
1833
- capacity: 10,
1834
- noteInputs: 1,
1835
- noteOutputs: 1,
1836
- sourceTrees: 2,
1837
- creditInputs: 1,
1838
- creditOutputs: 1,
1839
- creditRemainders: 0,
1840
- funding: "none",
1841
- permit: false,
1842
- deliveryBytes: 1162
1843
- },
1844
- circuit: {
1845
- circuitName: "credit_top_up",
1846
- target: "evm",
1847
- artifactSha256: "ee9dbcf8be6f6c09478190996e90b1d39d4a10a00245950f69fc1d2c329c6e9b",
1848
- vkSha256: "0c369fec0469b60baebb3be650bad42f3ccae6f0ff139cce6ad9a3f451ed7513"
1849
- },
1850
- samples: [
1851
- {
1852
- gasUsed: "1666948",
1853
- transactionHash: "0x1403da01167962a4349d2655ea217bfcfc1a2390138bea0279792c44b4381dd2",
1854
- blockNumber: "49",
1855
- blockHash: "0xcb554ffcdb4afe5f6458e5d23ffbdd1fdbef9c23f982343065772c0b3e3dd633",
1856
- calldataBytes: 12100
1857
- },
1858
- {
1859
- gasUsed: "1666900",
1860
- transactionHash: "0x3b5e54f29e3f888a443526cf23ab9255b3f0c7adf1d0d127c16b85f4c6a324d9",
1861
- blockNumber: "49",
1862
- blockHash: "0xeb304df6bdd24b249cac3197b543b0eaa6381ed75ad812dff248f914864105ed",
1863
- calldataBytes: 12100
1864
- },
1865
- {
1866
- gasUsed: "1666780",
1867
- transactionHash: "0x81c5ef25268a719275cb3b80618c2af291e1f7b3f91d7e82cc26bc894a8c332a",
1868
- blockNumber: "49",
1869
- blockHash: "0xfa42070d6349fc8d559b8bd4ad0ee6b79089107540c4472b9e492b8f5a6bd3e4",
1870
- calldataBytes: 12100
1871
- }
1872
- ]
1873
- },
1874
- {
1875
- id: "cancel-credit-1",
1876
- shape: {
1877
- kind: "cancel-credit",
1878
- target: "evm",
1879
- capacity: 1,
1880
- noteInputs: 0,
1881
- noteOutputs: 0,
1882
- sourceTrees: 1,
1883
- creditInputs: 1,
1884
- creditOutputs: 0,
1885
- creditRemainders: 0,
1886
- funding: "none",
1887
- permit: false,
1888
- deliveryBytes: 0
1889
- },
1890
- circuit: {
1891
- circuitName: "credit_cancel",
1892
- target: "evm",
1893
- artifactSha256: "d332453a2b8c2c544747ac8d5f01912c9757f48d986226fd6a9b0e24d8321474",
1894
- vkSha256: "1f8a3c20cb081d6a90962556da3124919cc4e5675e59ad31562af39299da02fb"
1895
- },
1896
- samples: [
1897
- {
1898
- gasUsed: "998146",
1899
- transactionHash: "0x97bc72692d241e2c344b912804f9939061db5ef59cf4bb23922d93812e382160",
1900
- blockNumber: "49",
1901
- blockHash: "0x2e09df4df84a1c25961386febe8404531bb5da274836d50cc15a26c91b433a98",
1902
- calldataBytes: 9540
1903
- },
1904
- {
1905
- gasUsed: "998134",
1906
- transactionHash: "0x26c5067b12c2bc4b694070784e6b19d4855efa6e77c2422f0c6b1567f061570a",
1907
- blockNumber: "49",
1908
- blockHash: "0xdd3f20520c09e001374cab58387e52c82446db053539e30dad28b0de679a333c",
1909
- calldataBytes: 9540
1910
- },
1911
- {
1912
- gasUsed: "998230",
1913
- transactionHash: "0x5dc09445a405150da1445c22f50d6dd10d8d428a6a3f41ee90db7d3574657e31",
1914
- blockNumber: "49",
1915
- blockHash: "0x5c8f8223a50d2c8d48188a2db28ffa33c1b150a2fb465e99db4430949db3664b",
1916
- calldataBytes: 9540
1917
- }
1918
- ]
1919
2561
  }
1920
2562
  ]
1921
2563
  }
@@ -1944,6 +2586,29 @@ function copyGasBenchmarks(profiles) {
1944
2586
  for (const p of copy) {
1945
2587
  if (p.formatVersion !== 1 || !p.id || !decimal.test(p.deployment.chainId) || !address.test(p.deployment.protocolAddress) || !address.test(p.deployment.tokenAddress) || !p.deployment.runtimeCodeHash || !word2.test(p.deployment.runtimeCodeHash) || p.source.verifier !== "real" || !/^[0-9a-f]{40}$/i.test(p.source.protocolCommit) || !p.source.measuredAt || !Array.isArray(p.source.assumptions) || !p.source.assumptions.every((assumption) => typeof assumption === "string") || !p.measurements.length)
1946
2588
  throw new Error("invalid gas benchmark profile");
2589
+ if (p.source.fingerprints && ![
2590
+ "protocolSourceSha256",
2591
+ "dirtyDiffSha256",
2592
+ "compiledArtifactsSha256",
2593
+ "creditManifestSha256",
2594
+ "userManifestSha256",
2595
+ "sdkSourceSha256"
2596
+ ].every((key) => {
2597
+ const v = p.source.fingerprints[key];
2598
+ return typeof v === "string" && /^[a-f0-9]{64}$/i.test(v);
2599
+ }))
2600
+ throw new Error("invalid benchmark source fingerprint");
2601
+ if (p.source.blockGasLimit !== void 0 && (!decimal.test(p.source.blockGasLimit) || BigInt(p.source.blockGasLimit) <= 0n))
2602
+ throw new Error("invalid benchmark block gas limit");
2603
+ if (p.source.runtimeContracts && !Object.values(p.source.runtimeContracts).every(
2604
+ (v) => address.test(v.address) && word2.test(v.runtimeCodeHash)
2605
+ ))
2606
+ throw new Error("invalid benchmark runtime identity");
2607
+ if (p.source.toolchain && (!["solidity", "barretenberg", "noir", "evmVersion", "anvil"].every((key) => {
2608
+ const v = p.source.toolchain[key];
2609
+ return typeof v === "string" && v.length > 0;
2610
+ }) || !Number.isSafeInteger(p.source.toolchain.optimizerRuns) || p.source.toolchain.optimizerRuns < 0))
2611
+ throw new Error("invalid benchmark toolchain");
1947
2612
  for (const m of p.measurements) {
1948
2613
  if (!m.id || !m.samples.length || !["none", "caller", "signature"].includes(m.shape.funding) || typeof m.shape.permit !== "boolean")
1949
2614
  throw new Error("invalid gas benchmark measurement");
@@ -2023,11 +2688,20 @@ function estimateBenchmarkGas(plan, protocol, profiles) {
2023
2688
  );
2024
2689
  if (!request.deployment.runtimeCodeHash || !candidates.length)
2025
2690
  return { ...base, available: false, reason: "deployment-not-covered" };
2026
- for (const profile of candidates) {
2027
- const measurement = profile.measurements.find(
2691
+ const exact = candidates.flatMap(
2692
+ (profile) => profile.measurements.filter(
2028
2693
  (m) => shapeKeys.every((key) => m.shape[key] === request.shape[key]) && sameCircuit(m.circuit, request.circuit)
2029
- );
2030
- if (!measurement) continue;
2694
+ ).map((measurement) => ({ profile, measurement }))
2695
+ );
2696
+ const mean = (measurement) => {
2697
+ const count = BigInt(measurement.samples.length);
2698
+ return (measurement.samples.reduce((sum, s) => sum + BigInt(s.gasUsed), 0n) + count - 1n) / count;
2699
+ };
2700
+ exact.sort(
2701
+ (a, b) => mean(a.measurement) > mean(b.measurement) ? -1 : mean(a.measurement) < mean(b.measurement) ? 1 : a.measurement.id.localeCompare(b.measurement.id)
2702
+ );
2703
+ if (exact.length) {
2704
+ const { profile, measurement } = exact[0];
2031
2705
  const gas = measurement.samples.map((sample) => BigInt(sample.gasUsed));
2032
2706
  const count = BigInt(gas.length);
2033
2707
  return {
@@ -2057,14 +2731,20 @@ function estimateShapeGas(request, profiles = defaultProfiles) {
2057
2731
  const matching = measurements.filter(
2058
2732
  (measurement) => measurement.shape.kind === request.shape.kind && measurement.shape.target === request.shape.target && sameCircuit(measurement.circuit, request.circuit)
2059
2733
  );
2060
- const exact = matching.find(
2734
+ const exact = matching.filter(
2061
2735
  (measurement) => shapeKeys.every((key) => measurement.shape[key] === request.shape[key])
2062
2736
  );
2063
- if (exact) {
2064
- const gas = exact.samples.map((sample) => BigInt(sample.gasUsed));
2065
- const count = BigInt(gas.length);
2066
- return { gasUnits: (gas.reduce((sum, value) => sum + value, 0n) + count - 1n) / count };
2737
+ if (exact.length) {
2738
+ const means = exact.map((m) => {
2739
+ const count = BigInt(m.samples.length);
2740
+ return (m.samples.reduce((sum, s) => sum + BigInt(s.gasUsed), 0n) + count - 1n) / count;
2741
+ });
2742
+ return { gasUnits: means.reduce((max, v) => v > max ? v : max) };
2067
2743
  }
2744
+ if (["create-credit", "draw-credit", "top-up-credit", "cancel-credit"].includes(
2745
+ request.shape.kind
2746
+ ) && !matching.length)
2747
+ throw new Error("No current Credit gas reference for this artifact and verification key");
2068
2748
  const candidates = matching.length ? matching : measurements.filter(
2069
2749
  (measurement) => measurement.shape.kind === request.shape.kind && measurement.shape.target === request.shape.target
2070
2750
  );
@@ -2079,7 +2759,22 @@ function estimateShapeGas(request, profiles = defaultProfiles) {
2079
2759
  "deliveryBytes",
2080
2760
  ...!matching.length ? ["capacity"] : []
2081
2761
  ];
2082
- const estimates = candidates.map((measurement) => {
2762
+ const groups = /* @__PURE__ */ new Map();
2763
+ for (const candidate of candidates) {
2764
+ const key = JSON.stringify([
2765
+ shapeKeys.map((k) => candidate.shape[k]),
2766
+ candidate.circuit?.circuitName,
2767
+ candidate.circuit?.target,
2768
+ candidate.circuit?.artifactSha256.toLowerCase(),
2769
+ candidate.circuit?.vkSha256.toLowerCase()
2770
+ ]);
2771
+ const previous = groups.get(key);
2772
+ groups.set(
2773
+ key,
2774
+ previous ? { ...candidate, samples: [...previous.samples, ...candidate.samples] } : candidate
2775
+ );
2776
+ }
2777
+ const estimates = [...groups.values()].map((measurement) => {
2083
2778
  let numerator = 1n;
2084
2779
  let denominator = 1n;
2085
2780
  for (const key of dimensions) {
@@ -2110,7 +2805,7 @@ function estimateGasReference(plan, protocol, profiles) {
2110
2805
 
2111
2806
  // src/session/operation-execution.ts
2112
2807
  var import_ethers6 = require("ethers");
2113
- var import_core3 = require("@invisi-labs/core");
2808
+ var import_core4 = require("@invisi-labs/core");
2114
2809
 
2115
2810
  // src/session/proof-integrity.ts
2116
2811
  var import_ethers5 = require("ethers");
@@ -2139,7 +2834,7 @@ async function authorizeOperation(plan, provider) {
2139
2834
  if (provider.walletIdentity !== plan.scope.walletIdentity)
2140
2835
  throw new Error("wallet authorization capability mismatch");
2141
2836
  const request = authorizationRequest(plan);
2142
- const digest = (0, import_core3.computeWalletAuthorizationDigest)(request);
2837
+ const digest = (0, import_core4.computeWalletAuthorizationDigest)(request);
2143
2838
  const signed = await provider.authorize(structuredClone(request));
2144
2839
  if (signed.walletIdentity !== plan.scope.walletIdentity || signed.digest !== digest)
2145
2840
  throw new Error("wallet authorization statement mismatch");
@@ -2223,11 +2918,11 @@ function operationPreview(plan, status) {
2223
2918
  }
2224
2919
 
2225
2920
  // src/session/Operation.ts
2226
- var import_core7 = require("@invisi-labs/core");
2921
+ var import_core8 = require("@invisi-labs/core");
2227
2922
  var import_protocol4 = require("@invisi-labs/protocol");
2228
2923
 
2229
2924
  // src/session/operation-confirmation.ts
2230
- var import_core6 = require("@invisi-labs/core");
2925
+ var import_core7 = require("@invisi-labs/core");
2231
2926
 
2232
2927
  // src/session/aggregate-receipt.ts
2233
2928
  var import_ethers7 = require("ethers");
@@ -2283,10 +2978,10 @@ function matchesAggregateTransaction(saved, transaction) {
2283
2978
  }
2284
2979
 
2285
2980
  // src/session/credit-values.ts
2286
- var import_core4 = require("@invisi-labs/core");
2981
+ var import_core5 = require("@invisi-labs/core");
2287
2982
  async function creditLeaf(state) {
2288
2983
  const n = state.note;
2289
- return (0, import_core4.computeCreditCommitment)(
2984
+ return (0, import_core5.computeCreditCommitment)(
2290
2985
  n.chainId,
2291
2986
  n.spenderWalletIdentity,
2292
2987
  n.ownerWalletIdentity,
@@ -2296,22 +2991,23 @@ async function creditLeaf(state) {
2296
2991
  n.amount,
2297
2992
  n.nonce,
2298
2993
  n.expiry,
2299
- await (0, import_core4.computeCreditSharedKeyHash)(n.creditSharedKey)
2994
+ await (0, import_core5.computeCreditSharedKeyHash)(n.creditSharedKey),
2995
+ n
2300
2996
  );
2301
2997
  }
2302
2998
 
2303
2999
  // src/session/membership.ts
2304
- var import_core5 = require("@invisi-labs/core");
3000
+ var import_core6 = require("@invisi-labs/core");
2305
3001
  async function verifyMembership(reader, context, block, input, proof) {
2306
3002
  if (proof.block.hash !== block.hash || proof.block.number !== block.number || proof.leaf !== input.commitment || proof.treeId !== input.treeId || proof.leafIndex !== input.leafIndex || proof.path.length !== 16 || !Number.isInteger(input.leafIndex) || input.leafIndex < 0 || input.leafIndex >= 65536 || !await reader.isKnownRoot(context, input.treeId, proof.root, block))
2307
3003
  throw new Error("membership context/root mismatch");
2308
3004
  let root = BigInt(input.commitment);
2309
3005
  for (let i = 0; i < 16; i++) {
2310
3006
  const sibling = proof.path[i];
2311
- if (typeof sibling !== "bigint" || sibling < 0n || sibling >= import_core5.FIELD_MODULUS)
3007
+ if (typeof sibling !== "bigint" || sibling < 0n || sibling >= import_core6.FIELD_MODULUS)
2312
3008
  throw new Error("noncanonical membership path");
2313
3009
  root = BigInt(
2314
- await (0, import_core5.poseidonHash)(input.leafIndex >> i & 1 ? [sibling, root] : [root, sibling])
3010
+ await (0, import_core6.poseidonHash)(input.leafIndex >> i & 1 ? [sibling, root] : [root, sibling])
2315
3011
  );
2316
3012
  }
2317
3013
  if (root !== BigInt(proof.root))
@@ -2483,7 +3179,7 @@ async function confirmOperation(runtime, id, generation, hash2, signal) {
2483
3179
  if (credits.length) {
2484
3180
  const nullifiers = await Promise.all(
2485
3181
  credits.map(
2486
- async (record) => (0, import_core6.computeCreditNullifier)(
3182
+ async (record) => (0, import_core7.computeCreditNullifier)(
2487
3183
  plan.context.chainId,
2488
3184
  record.state.note.creditSharedKey,
2489
3185
  await creditLeaf(record.state)
@@ -2815,7 +3511,7 @@ var Operation = class _Operation {
2815
3511
  }
2816
3512
  const prover = this.#runtime.options.prover;
2817
3513
  if (!prover) {
2818
- throw new import_core7.MissingCapabilityError("prover");
3514
+ throw new import_core8.MissingCapabilityError("prover");
2819
3515
  }
2820
3516
  return this.stage(
2821
3517
  "proof",
@@ -2849,7 +3545,7 @@ var Operation = class _Operation {
2849
3545
  check6(p.kind === "shield" || this.#saved.proof, "proof must precede funding authorization");
2850
3546
  const signer = this.#runtime.options.fundingSigner;
2851
3547
  if (!signer) {
2852
- throw new import_core7.MissingCapabilityError("EVM funding signer");
3548
+ throw new import_core8.MissingCapabilityError("EVM funding signer");
2853
3549
  }
2854
3550
  check6(
2855
3551
  signer.address.toLowerCase() === p.funding.payer.toLowerCase(),
@@ -3040,7 +3736,7 @@ var Operation = class _Operation {
3040
3736
 
3041
3737
  // src/session/WalletSession.ts
3042
3738
  var import_ethers11 = require("ethers");
3043
- var import_core12 = require("@invisi-labs/core");
3739
+ var import_core13 = require("@invisi-labs/core");
3044
3740
 
3045
3741
  // src/session/transaction-preparation.ts
3046
3742
  var import_ethers10 = require("ethers");
@@ -3048,7 +3744,7 @@ var import_protocol7 = require("@invisi-labs/protocol");
3048
3744
 
3049
3745
  // src/session/prepare-common.ts
3050
3746
  var import_ethers8 = require("ethers");
3051
- var import_core8 = require("@invisi-labs/core");
3747
+ var import_core9 = require("@invisi-labs/core");
3052
3748
  var import_protocol5 = require("@invisi-labs/protocol");
3053
3749
 
3054
3750
  // src/session/selection.ts
@@ -3104,7 +3800,15 @@ var Preparation = class {
3104
3800
  throw new Error("canonical wallet checkpoint changed; resync required");
3105
3801
  }
3106
3802
  }
3107
- return { context: { ...options.protocol.context, now: block.timestamp }, block, deadline };
3803
+ return {
3804
+ context: {
3805
+ ...options.protocol.context,
3806
+ now: block.timestamp,
3807
+ timestamp: block.timestamp
3808
+ },
3809
+ block,
3810
+ deadline
3811
+ };
3108
3812
  }
3109
3813
  async assertBlock(frame) {
3110
3814
  if ((await this.runtime.reader.getBlock(frame.block.number)).hash !== frame.block.hash) {
@@ -3145,12 +3849,12 @@ var Preparation = class {
3145
3849
  }
3146
3850
  async output(payment, context, change = false) {
3147
3851
  positiveAmount(payment.amount);
3148
- const recipient = await import_core8.ReceivingAddress.parse(payment.to).resolve(
3852
+ const recipient = await import_core9.ReceivingAddress.parse(payment.to).resolve(
3149
3853
  this.runtime.options.addressResolver
3150
3854
  );
3151
- const memo = (0, import_core8.encodeMemo)(payment.memo);
3152
- const nonce = (0, import_core8.generateNonce)();
3153
- const identity = await (0, import_core8.computeNoteIdentity)(BigInt(recipient.walletIdentity), nonce);
3855
+ const memo = (0, import_core9.encodeMemo)(payment.memo);
3856
+ const nonce = (0, import_core9.generateNonce)();
3857
+ const identity = await (0, import_core9.computeNoteIdentity)(BigInt(recipient.walletIdentity), nonce);
3154
3858
  const keys = recipient.getReceivingKeys();
3155
3859
  const note = {
3156
3860
  chainId: context.chainId,
@@ -3161,7 +3865,7 @@ var Preparation = class {
3161
3865
  ...memo.length === 0 ? {} : { memo },
3162
3866
  nonce
3163
3867
  };
3164
- const commitment = await (0, import_core8.computeNoteCommitment)(
3868
+ const commitment = await (0, import_core9.computeNoteCommitment)(
3165
3869
  context.chainId,
3166
3870
  identity,
3167
3871
  note.tokenAddress,
@@ -3175,20 +3879,20 @@ var Preparation = class {
3175
3879
  change,
3176
3880
  delivery: {
3177
3881
  ciphertext: (0, import_ethers8.hexlify)(
3178
- await (0, import_core8.encryptPrivateTransferNote)(keys.viewingPublicKey, note, {
3882
+ await (0, import_core9.encryptPrivateTransferNote)(keys.viewingPublicKey, note, {
3179
3883
  chainId: context.chainId,
3180
3884
  protocolAddress: note.protocolAddress,
3181
3885
  outputCommitment: commitment
3182
3886
  })
3183
3887
  ),
3184
- clue: (0, import_ethers8.hexlify)((0, import_core8.createClue)(keys.clueKey))
3888
+ clue: (0, import_ethers8.hexlify)((0, import_core9.createClue)(keys.clueKey))
3185
3889
  }
3186
3890
  };
3187
3891
  }
3188
3892
  async membership(input, frame) {
3189
3893
  const { options, reader } = this.runtime;
3190
3894
  if (!options.protocolRpc)
3191
- throw new import_core8.MissingCapabilityError("Protocol RPC membership provider");
3895
+ throw new import_core9.MissingCapabilityError("Protocol RPC membership provider");
3192
3896
  const root = this.#roots.get(input.treeId);
3193
3897
  const proof = await options.protocolRpc.getMembership(
3194
3898
  frame.context,
@@ -3235,9 +3939,9 @@ var Preparation = class {
3235
3939
  for (const input of selected) {
3236
3940
  const note = input.note;
3237
3941
  const c = frame.context;
3238
- if (note.walletIdentity !== scope.walletIdentity || note.chainId !== c.chainId || note.protocolAddress !== BigInt(c.protocolAddress) || note.tokenAddress !== BigInt(c.tokenAddress) || await (0, import_core8.computeNoteCommitment)(
3942
+ if (note.walletIdentity !== scope.walletIdentity || note.chainId !== c.chainId || note.protocolAddress !== BigInt(c.protocolAddress) || note.tokenAddress !== BigInt(c.tokenAddress) || await (0, import_core9.computeNoteCommitment)(
3239
3943
  c.chainId,
3240
- await (0, import_core8.computeNoteIdentity)(BigInt(note.walletIdentity), note.nonce),
3944
+ await (0, import_core9.computeNoteIdentity)(BigInt(note.walletIdentity), note.nonce),
3241
3945
  note.tokenAddress,
3242
3946
  note.amount
3243
3947
  ) !== input.commitment) {
@@ -3289,7 +3993,7 @@ function storedCandidates(inputs) {
3289
3993
 
3290
3994
  // src/session/prepare-credit.ts
3291
3995
  var import_ethers9 = require("ethers");
3292
- var import_core9 = require("@invisi-labs/core");
3996
+ var import_core10 = require("@invisi-labs/core");
3293
3997
  var import_protocol6 = require("@invisi-labs/protocol");
3294
3998
  var EMPTY = { ciphertext: "0x", clue: "0x" };
3295
3999
  var CreditPreparation = class {
@@ -3305,7 +4009,7 @@ var CreditPreparation = class {
3305
4009
  return value;
3306
4010
  }
3307
4011
  async seal(input, frame) {
3308
- const state = (0, import_core9.normalizeCreditDeliveryState)(input);
4012
+ const state = (0, import_core10.normalizeCreditDeliveryState)(input);
3309
4013
  const commitment = await creditLeaf(state);
3310
4014
  const context = {
3311
4015
  chainId: frame.context.chainId,
@@ -3317,9 +4021,9 @@ var CreditPreparation = class {
3317
4021
  const keys = role === "owner" ? state.ownerReceivingKeys : state.spenderReceivingKeys;
3318
4022
  return {
3319
4023
  ciphertext: (0, import_ethers9.hexlify)(
3320
- await (0, import_core9.encryptCreditNote)(keys.viewingPublicKey, state, { ...context, role })
4024
+ await (0, import_core10.encryptCreditNote)(keys.viewingPublicKey, state, { ...context, role })
3321
4025
  ),
3322
- clue: (0, import_ethers9.hexlify)((0, import_core9.createClue)(keys.clueKey))
4026
+ clue: (0, import_ethers9.hexlify)((0, import_core10.createClue)(keys.clueKey))
3323
4027
  };
3324
4028
  })
3325
4029
  );
@@ -3330,14 +4034,14 @@ var CreditPreparation = class {
3330
4034
  if (!stored || stored.spent !== "unspent" || stored.role !== role) {
3331
4035
  throw new Error(`confirmed unspent ${role} Credit is unavailable`);
3332
4036
  }
3333
- const state = (0, import_core9.normalizeCreditDeliveryState)(stored.state);
4037
+ const state = (0, import_core10.normalizeCreditDeliveryState)(stored.state);
3334
4038
  const n = state.note;
3335
4039
  if ((role === "owner" ? n.ownerWalletIdentity : n.spenderWalletIdentity) !== this.runtime.scope.walletIdentity || n.chainId !== frame.context.chainId || n.protocolAddress !== BigInt(frame.context.protocolAddress) || n.tokenAddress !== BigInt(frame.context.tokenAddress) || await creditLeaf(state) !== commitment) {
3336
4040
  throw new Error("Credit role, commitment or deployment mismatch");
3337
4041
  }
3338
4042
  const proof = await this.#prepare.membership(stored, frame);
3339
4043
  const path = [...proof.path];
3340
- const nullifier = await (0, import_core9.computeCreditNullifier)(n.chainId, n.creditSharedKey, commitment);
4044
+ const nullifier = await (0, import_core10.computeCreditNullifier)(n.chainId, n.creditSharedKey, commitment);
3341
4045
  await this.#prepare.assertUnspent([nullifier], frame);
3342
4046
  return {
3343
4047
  input: {
@@ -3374,7 +4078,7 @@ var CreditPreparation = class {
3374
4078
  positiveAmount(options.amount, 126);
3375
4079
  const frame = await this.#prepare.frame(options.deadline);
3376
4080
  const expiry = this.expiry(options.expiry, frame);
3377
- const spender = await import_core9.ReceivingAddress.parse(options.spender).resolve(
4081
+ const spender = await import_core10.ReceivingAddress.parse(options.spender).resolve(
3378
4082
  this.runtime.options.addressResolver
3379
4083
  );
3380
4084
  const owner = await this.runtime.options.wallet.getReceivingAddress().resolve(this.runtime.options.addressResolver);
@@ -3393,11 +4097,16 @@ var CreditPreparation = class {
3393
4097
  spenderWalletIdentity: spender.walletIdentity,
3394
4098
  ownerPayout: BigInt(ownerPayout),
3395
4099
  spenderPayout: BigInt(spenderPayout),
4100
+ ...(0, import_core10.normalizeCreditPolicy)({
4101
+ singleLimit: options.singleLimit ?? 0n,
4102
+ dailyLimit: options.dailyLimit ?? 0n,
4103
+ monthlyLimit: options.monthlyLimit ?? 0n
4104
+ }),
3396
4105
  amount: options.amount,
3397
4106
  ...options.memo === void 0 ? {} : { memo: options.memo },
3398
4107
  expiry,
3399
- nonce: (0, import_core9.generateNonce)(),
3400
- creditSharedKey: (0, import_core9.generateCreditSharedKey)()
4108
+ nonce: (0, import_core10.generateNonce)(),
4109
+ creditSharedKey: (0, import_core10.generateCreditSharedKey)()
3401
4110
  },
3402
4111
  ownerReceivingKeys: owner.getReceivingKeys(),
3403
4112
  spenderReceivingKeys: spender.getReceivingKeys()
@@ -3490,9 +4199,12 @@ var CreditPreparation = class {
3490
4199
  ...old,
3491
4200
  note: {
3492
4201
  ...old.note,
4202
+ singleLimit: options.singleLimit ?? old.note.singleLimit ?? 0n,
4203
+ dailyLimit: options.dailyLimit ?? old.note.dailyLimit ?? 0n,
4204
+ monthlyLimit: options.monthlyLimit ?? old.note.monthlyLimit ?? 0n,
3493
4205
  amount,
3494
4206
  expiry,
3495
- nonce: (0, import_core9.generateNonce)(),
4207
+ nonce: (0, import_core10.generateNonce)(),
3496
4208
  ...options.memo === void 0 ? {} : { memo: options.memo }
3497
4209
  }
3498
4210
  },
@@ -3541,6 +4253,7 @@ var CreditPreparation = class {
3541
4253
  }
3542
4254
  sources.set(member.source.treeId, member.source.merkleRoot);
3543
4255
  amounts.push(amount);
4256
+ const usage = (0, import_core10.applyCreditDrawUsage)(n, amount, frame.block.timestamp);
3544
4257
  const remaining = n.amount - amount;
3545
4258
  if (remaining === 0n) {
3546
4259
  remainders.push((0, import_protocol6.word)(0n));
@@ -3560,9 +4273,10 @@ var CreditPreparation = class {
3560
4273
  ...state,
3561
4274
  note: {
3562
4275
  ...n,
4276
+ ...usage,
3563
4277
  amount: remaining,
3564
4278
  ...options.credits[i].memo === void 0 ? {} : { memo: options.credits[i].memo },
3565
- nonce: await (0, import_core9.deriveRemainderNonce)(...args)
4279
+ nonce: await (0, import_core10.deriveRemainderNonce)(...args)
3566
4280
  }
3567
4281
  },
3568
4282
  frame
@@ -3570,7 +4284,7 @@ var CreditPreparation = class {
3570
4284
  outputs.push(output);
3571
4285
  remainders.push(output.commitment);
3572
4286
  recoveryAmounts.push(
3573
- (0, import_protocol6.word)((remaining + await (0, import_core9.computeCreditRecoveryPad)(...args)) % import_core9.FIELD_MODULUS)
4287
+ (0, import_protocol6.word)((remaining + await (0, import_core10.computeCreditRecoveryPad)(...args)) % import_core10.FIELD_MODULUS)
3574
4288
  );
3575
4289
  deliveries.push(...output.deliveries);
3576
4290
  }
@@ -3891,10 +4605,10 @@ async function refreshWallet(runtime, options) {
3891
4605
  }
3892
4606
 
3893
4607
  // src/session/WalletUpdater.ts
3894
- var import_core11 = require("@invisi-labs/core");
4608
+ var import_core12 = require("@invisi-labs/core");
3895
4609
 
3896
4610
  // src/session/inventory.ts
3897
- var import_core10 = require("@invisi-labs/core");
4611
+ var import_core11 = require("@invisi-labs/core");
3898
4612
  var CanonicalConflict = class extends Error {
3899
4613
  };
3900
4614
  var CreditMetadataMismatch = class extends Error {
@@ -3946,10 +4660,10 @@ var InventoryProcessor = class {
3946
4660
  }
3947
4661
  async creditNullifier(state) {
3948
4662
  const n = state.note;
3949
- return (0, import_core10.computeCreditNullifier)(
4663
+ return (0, import_core11.computeCreditNullifier)(
3950
4664
  n.chainId,
3951
4665
  n.creditSharedKey,
3952
- await (0, import_core10.computeCreditCommitment)(
4666
+ await (0, import_core11.computeCreditCommitment)(
3953
4667
  n.chainId,
3954
4668
  n.spenderWalletIdentity,
3955
4669
  n.ownerWalletIdentity,
@@ -3959,7 +4673,8 @@ var InventoryProcessor = class {
3959
4673
  n.amount,
3960
4674
  n.nonce,
3961
4675
  n.expiry,
3962
- await (0, import_core10.computeCreditSharedKeyHash)(n.creditSharedKey)
4676
+ await (0, import_core11.computeCreditSharedKeyHash)(n.creditSharedKey),
4677
+ n
3963
4678
  )
3964
4679
  );
3965
4680
  }
@@ -4006,6 +4721,9 @@ var InventoryProcessor = class {
4006
4721
  };
4007
4722
  for (const event of logs) {
4008
4723
  if (event.eventName === "CreditDraw") {
4724
+ const block = await this.#options.reader.getBlock(event.blockNumber);
4725
+ if (block.hash !== event.blockHash)
4726
+ throw new CanonicalConflict("draw block changed during Credit recovery");
4009
4727
  const args = event.args;
4010
4728
  const params = args.params;
4011
4729
  const indices = args.remainderLeafIndices;
@@ -4019,10 +4737,11 @@ var InventoryProcessor = class {
4019
4737
  previous.state.note.expiry === params.expiries[index2],
4020
4738
  "draw recovery expiry mismatch"
4021
4739
  );
4022
- const remainder = await (0, import_core10.recoverCreditRemainder)(
4740
+ const remainder = await (0, import_core11.recoverCreditRemainder)(
4023
4741
  context,
4024
4742
  previous.state.note,
4025
4743
  {
4744
+ timestamp: block.timestamp,
4026
4745
  creditNullifier: nullifier,
4027
4746
  remainderCommitment: params.remainderCommitments[index2],
4028
4747
  recoveryAmount: BigInt(params.recoveryAmounts[index2])
@@ -4047,7 +4766,7 @@ var InventoryProcessor = class {
4047
4766
  ...clone(previous.state),
4048
4767
  note: {
4049
4768
  ...remainder,
4050
- ...memo === void 0 ? {} : { memo: (0, import_core10.encodeMemo)(memo) }
4769
+ ...memo === void 0 ? {} : { memo: (0, import_core11.encodeMemo)(memo) }
4051
4770
  }
4052
4771
  },
4053
4772
  receivingKeySource: { kind: "draw", commitment: previous.commitment },
@@ -4126,7 +4845,7 @@ var WalletUpdater = class extends InventoryProcessor {
4126
4845
  }
4127
4846
  async run(batch, options) {
4128
4847
  const { reader, protocol, scope, store, viewing } = this.#options;
4129
- const nullifier = import_core11.NullifierCapability.fromIdentity(scope.walletIdentity);
4848
+ const nullifier = import_core12.NullifierCapability.fromIdentity(scope.walletIdentity);
4130
4849
  const { signal, reset } = options;
4131
4850
  signal?.throwIfAborted();
4132
4851
  const context = protocol.context;
@@ -4347,7 +5066,7 @@ var WalletSession = class {
4347
5066
  /** Delegate sending to ethers; managed operations additionally retain the resulting hash. */
4348
5067
  async sendTransaction(input, options = {}) {
4349
5068
  const signer = this.#options.signer;
4350
- if (!signer) throw new import_core12.MissingCapabilityError("ethers signer");
5069
+ if (!signer) throw new import_core13.MissingCapabilityError("ethers signer");
4351
5070
  const operation = input instanceof Operation ? input : void 0;
4352
5071
  if (operation && this.#sending.has(operation.id))
4353
5072
  throw new Error("operation is already being sent by this session");
@@ -4355,12 +5074,12 @@ var WalletSession = class {
4355
5074
  const overrides = { ...options };
4356
5075
  const plain = operation ? void 0 : { ...input };
4357
5076
  try {
4358
- if (!signer.provider) throw new import_core12.MissingCapabilityError("connected ethers signer");
5077
+ if (!signer.provider) throw new import_core13.MissingCapabilityError("connected ethers signer");
4359
5078
  if ((await signer.provider.getNetwork()).chainId !== this.protocol.context.chainId) {
4360
5079
  throw new Error("signer-provider session chain mismatch");
4361
5080
  }
4362
5081
  if (operation) {
4363
- if (!this.#options.store) throw new import_core12.MissingCapabilityError("wallet store");
5082
+ if (!this.#options.store) throw new import_core13.MissingCapabilityError("wallet store");
4364
5083
  const state = await this.#options.store.readSnapshot(this.scope);
4365
5084
  if (!state.operations[operation.id])
4366
5085
  throw new Error("operation does not belong to this wallet session");
@@ -4391,10 +5110,10 @@ var WalletSession = class {
4391
5110
  runtime(tokenAddress) {
4392
5111
  const options = this.#options;
4393
5112
  if (!options.store) {
4394
- throw new import_core12.MissingCapabilityError("wallet store");
5113
+ throw new import_core13.MissingCapabilityError("wallet store");
4395
5114
  }
4396
5115
  if (!options.chainReader) {
4397
- throw new import_core12.MissingCapabilityError("chain reader");
5116
+ throw new import_core13.MissingCapabilityError("chain reader");
4398
5117
  }
4399
5118
  return {
4400
5119
  options: { ...options, protocol: options.protocol.forToken(tokenAddress) },
@@ -4408,7 +5127,7 @@ var WalletSession = class {
4408
5127
  if (this.#updater) return this.#updater;
4409
5128
  const options = this.#options;
4410
5129
  if (!options.store || !options.chainReader || !options.protocolRpc)
4411
- throw new import_core12.MissingCapabilityError("wallet store, chain reader and Protocol RPC");
5130
+ throw new import_core13.MissingCapabilityError("wallet store, chain reader and Protocol RPC");
4412
5131
  const viewing = options.viewing ?? options.wallet.getViewer();
4413
5132
  const receivingAddress = options.wallet.getReceivingAddress();
4414
5133
  const receivingKeys = receivingAddress.kind === "long" ? receivingAddress.getReceivingKeys() : void 0;
@@ -4426,7 +5145,7 @@ var WalletSession = class {
4426
5145
  async balance(tokenAddress) {
4427
5146
  const store = this.#options.store;
4428
5147
  if (!store) {
4429
- throw new import_core12.MissingCapabilityError("wallet store");
5148
+ throw new import_core13.MissingCapabilityError("wallet store");
4430
5149
  }
4431
5150
  return walletBalance(await store.readSnapshot(this.scope), (0, import_ethers11.getAddress)(tokenAddress));
4432
5151
  }
@@ -4434,8 +5153,8 @@ var WalletSession = class {
4434
5153
  async refresh(options) {
4435
5154
  const provider = this.#options.protocolRpc;
4436
5155
  const reader = this.#options.chainReader;
4437
- if (!reader) throw new import_core12.MissingCapabilityError("chain reader");
4438
- if (!provider) throw new import_core12.MissingCapabilityError("Protocol RPC");
5156
+ if (!reader) throw new import_core13.MissingCapabilityError("chain reader");
5157
+ if (!provider) throw new import_core13.MissingCapabilityError("Protocol RPC");
4439
5158
  const updater = this.updater();
4440
5159
  const request = {
4441
5160
  ...options,
@@ -4494,7 +5213,7 @@ var WalletSession = class {
4494
5213
  }
4495
5214
  async resume(operationId) {
4496
5215
  const store = this.#options.store;
4497
- if (!store) throw new import_core12.MissingCapabilityError("wallet store");
5216
+ if (!store) throw new import_core13.MissingCapabilityError("wallet store");
4498
5217
  const state = await store.readSnapshot(this.scope);
4499
5218
  const saved = state.operations[operationId]?.payload;
4500
5219
  if (!saved?.plan) throw new Error("operation not found");