@invisi-labs/sdk 1.1.1 → 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
@@ -516,25 +516,27 @@ function extractDeliveryCandidates(logs, context, confirmedThrough) {
516
516
  const tokens = array(a.tokens);
517
517
  const cs = array(a.commitments), tree = integer(a.treeId), start = index(a.startLeafIndex), packed = a.packedDeliveries;
518
518
  check2(
519
- typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed) && packed.length === 2 + 452 * cs.length,
519
+ typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed),
520
520
  "invalid packed deliveries"
521
521
  );
522
522
  check2(tokens.length === cs.length, "batch token count mismatch");
523
+ check2(start + cs.length <= 65536, "batch exceeds tree capacity");
524
+ let offset = 2;
523
525
  cs.forEach((c, i) => {
524
- const segment = packed.slice(2 + 452 * i, 2 + 452 * (i + 1));
525
- add(
526
- log,
527
- tree,
528
- start + i,
529
- c,
530
- "funds",
531
- {
532
- ciphertext: `0x${segment.slice(0, 316)}`,
533
- clue: `0x${segment.slice(316)}`
534
- },
535
- tokens[i]
526
+ check2(offset + 4 <= packed.length, "truncated delivery length prefix");
527
+ const length = Number.parseInt(packed.slice(offset, offset + 4), 16);
528
+ offset += 4;
529
+ check2(
530
+ length >= 160 && length <= 416 && offset + length * 2 + 136 <= packed.length,
531
+ "invalid packed delivery length"
536
532
  );
533
+ const ciphertext = `0x${packed.slice(offset, offset + length * 2)}`;
534
+ offset += length * 2;
535
+ const clue = `0x${packed.slice(offset, offset + 136)}`;
536
+ offset += 136;
537
+ add(log, tree, start + i, c, "funds", { ciphertext, clue }, tokens[i]);
537
538
  });
539
+ check2(offset === packed.length, "trailing packed delivery bytes");
538
540
  } else if (log.eventName === "CreditCreated") creation(log, a, a);
539
541
  else if (log.eventName === "CreditToppedUp")
540
542
  creation(log, a, object(object(a.params).creation));
@@ -1033,6 +1035,7 @@ var MemoryAtomicRecords = class {
1033
1035
  };
1034
1036
 
1035
1037
  // src/session/operation-protocol.ts
1038
+ var import_core3 = require("@invisi-labs/core");
1036
1039
  var import_protocol2 = require("@invisi-labs/protocol");
1037
1040
  function requiresAuthorization(plan) {
1038
1041
  if (plan.kind === "sweep") {
@@ -1170,6 +1173,7 @@ async function witnessFor(protocol, plan, authorization) {
1170
1173
  }
1171
1174
  if (credit.draw) {
1172
1175
  return builder.drawCredit({
1176
+ timestamp: plan.preparedAt.timestamp,
1173
1177
  params: credit.draw,
1174
1178
  deliveries: credit.deliveries,
1175
1179
  inputs: credit.inputs,
@@ -1300,12 +1304,836 @@ function operationExpired(plan, now) {
1300
1304
  const credit = plan.credit;
1301
1305
  if (credit?.topUp && now >= credit.topUp.previousExpiry) return true;
1302
1306
  if (credit?.creation && now >= credit.creation.expiry) return true;
1303
- 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
+ }
1304
1313
  return false;
1305
1314
  }
1306
1315
 
1307
1316
  // src/data/gas-benchmarks.json
1308
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
+ },
1309
2137
  {
1310
2138
  formatVersion: 1,
1311
2139
  id: "protocol-92ef274-osaka-real",
@@ -1730,190 +2558,6 @@ var gas_benchmarks_default = [
1730
2558
  calldataBytes: 10116
1731
2559
  }
1732
2560
  ]
1733
- },
1734
- {
1735
- id: "create-credit-1x1",
1736
- shape: {
1737
- kind: "create-credit",
1738
- target: "evm",
1739
- capacity: 10,
1740
- noteInputs: 1,
1741
- noteOutputs: 1,
1742
- sourceTrees: 1,
1743
- creditInputs: 0,
1744
- creditOutputs: 1,
1745
- creditRemainders: 0,
1746
- funding: "none",
1747
- permit: false,
1748
- deliveryBytes: 1162
1749
- },
1750
- circuit: {
1751
- circuitName: "create_credit",
1752
- target: "evm",
1753
- artifactSha256: "ab97cd5a036851a9748a5cfd8e6f9834e23090c8e95db4531aabfc37d3abb353",
1754
- vkSha256: "fac0e65b768a28750323cca851990598af936611125b6cfa3f5c16b04c7d084f"
1755
- },
1756
- samples: [
1757
- {
1758
- gasUsed: "1627325",
1759
- transactionHash: "0x7763d93a5b1e8797b5f4af2e1e5b1bb029a8b0f9f7b90bcc04f581947d826803",
1760
- blockNumber: "49",
1761
- blockHash: "0x93e51ae5e99c68dc642693d478e444330d8e26255ff5bb9aafc4a3f4e70d3a45",
1762
- calldataBytes: 11940
1763
- },
1764
- {
1765
- gasUsed: "1627385",
1766
- transactionHash: "0xe246d59cafa2a26dddf21c8385dd843be4d4596388ebe23e936df84e7f906635",
1767
- blockNumber: "49",
1768
- blockHash: "0x3c24b2d6ed2a998562d34b49e0517515742a9b39d59aec38a9ac6b22be1b694b",
1769
- calldataBytes: 11940
1770
- },
1771
- {
1772
- gasUsed: "1627157",
1773
- transactionHash: "0x2f7ed0b75435cc6a820d0cd90fd82d362f74787057413722b6eb3c6e37db87d3",
1774
- blockNumber: "49",
1775
- blockHash: "0x0a0301670b46017da772800c68bb941245ac1941c79fde9c85717632154e15ee",
1776
- calldataBytes: 11940
1777
- }
1778
- ]
1779
- },
1780
- {
1781
- id: "draw-credit-1-partial",
1782
- shape: {
1783
- kind: "draw-credit",
1784
- target: "evm",
1785
- capacity: 1,
1786
- noteInputs: 0,
1787
- noteOutputs: 0,
1788
- sourceTrees: 1,
1789
- creditInputs: 1,
1790
- creditOutputs: 1,
1791
- creditRemainders: 1,
1792
- funding: "none",
1793
- permit: false,
1794
- deliveryBytes: 936
1795
- },
1796
- circuit: {
1797
- circuitName: "credit_draw_slots1",
1798
- target: "evm",
1799
- artifactSha256: "f5e458790948f37a61a833fad52cf2cc3b26a59515d271de32e0caaa4e229eb5",
1800
- vkSha256: "613699a440f50a0937e4c57e5152b5fdea42c31b10157d6b93226fef313df553"
1801
- },
1802
- samples: [
1803
- {
1804
- gasUsed: "1581294",
1805
- transactionHash: "0xd438e22b0fa07a657279f182537e4996f1936f0881d5b7d637845f8ca2808aab",
1806
- blockNumber: "49",
1807
- blockHash: "0x9e384a3054530b1ff237a639bca1a559afb2b73b30e21c262aac85ebf480fc9b",
1808
- calldataBytes: 11396
1809
- },
1810
- {
1811
- gasUsed: "1581402",
1812
- transactionHash: "0xa70ac3e7284b6e98f8591a6ba88e4ddfb23ecbd05343641d0532f34920e10b56",
1813
- blockNumber: "49",
1814
- blockHash: "0x37c5eb34ce96a841e96c36103a7ab65c1a3e08603dc9843efb0c0752c069f1d4",
1815
- calldataBytes: 11396
1816
- },
1817
- {
1818
- gasUsed: "1581174",
1819
- transactionHash: "0xd062494979d0bc0e284ccb070f87b48f3e8e5befb6001f15a006dd2a4a72ca24",
1820
- blockNumber: "49",
1821
- blockHash: "0x12840d920f14163b2d29491f28cee616e1bb9fd9514a4debe10ae35256345fc1",
1822
- calldataBytes: 11396
1823
- }
1824
- ]
1825
- },
1826
- {
1827
- id: "top-up-credit-1x1",
1828
- shape: {
1829
- kind: "top-up-credit",
1830
- target: "evm",
1831
- capacity: 10,
1832
- noteInputs: 1,
1833
- noteOutputs: 1,
1834
- sourceTrees: 2,
1835
- creditInputs: 1,
1836
- creditOutputs: 1,
1837
- creditRemainders: 0,
1838
- funding: "none",
1839
- permit: false,
1840
- deliveryBytes: 1162
1841
- },
1842
- circuit: {
1843
- circuitName: "credit_top_up",
1844
- target: "evm",
1845
- artifactSha256: "ee9dbcf8be6f6c09478190996e90b1d39d4a10a00245950f69fc1d2c329c6e9b",
1846
- vkSha256: "0c369fec0469b60baebb3be650bad42f3ccae6f0ff139cce6ad9a3f451ed7513"
1847
- },
1848
- samples: [
1849
- {
1850
- gasUsed: "1666948",
1851
- transactionHash: "0x1403da01167962a4349d2655ea217bfcfc1a2390138bea0279792c44b4381dd2",
1852
- blockNumber: "49",
1853
- blockHash: "0xcb554ffcdb4afe5f6458e5d23ffbdd1fdbef9c23f982343065772c0b3e3dd633",
1854
- calldataBytes: 12100
1855
- },
1856
- {
1857
- gasUsed: "1666900",
1858
- transactionHash: "0x3b5e54f29e3f888a443526cf23ab9255b3f0c7adf1d0d127c16b85f4c6a324d9",
1859
- blockNumber: "49",
1860
- blockHash: "0xeb304df6bdd24b249cac3197b543b0eaa6381ed75ad812dff248f914864105ed",
1861
- calldataBytes: 12100
1862
- },
1863
- {
1864
- gasUsed: "1666780",
1865
- transactionHash: "0x81c5ef25268a719275cb3b80618c2af291e1f7b3f91d7e82cc26bc894a8c332a",
1866
- blockNumber: "49",
1867
- blockHash: "0xfa42070d6349fc8d559b8bd4ad0ee6b79089107540c4472b9e492b8f5a6bd3e4",
1868
- calldataBytes: 12100
1869
- }
1870
- ]
1871
- },
1872
- {
1873
- id: "cancel-credit-1",
1874
- shape: {
1875
- kind: "cancel-credit",
1876
- target: "evm",
1877
- capacity: 1,
1878
- noteInputs: 0,
1879
- noteOutputs: 0,
1880
- sourceTrees: 1,
1881
- creditInputs: 1,
1882
- creditOutputs: 0,
1883
- creditRemainders: 0,
1884
- funding: "none",
1885
- permit: false,
1886
- deliveryBytes: 0
1887
- },
1888
- circuit: {
1889
- circuitName: "credit_cancel",
1890
- target: "evm",
1891
- artifactSha256: "d332453a2b8c2c544747ac8d5f01912c9757f48d986226fd6a9b0e24d8321474",
1892
- vkSha256: "1f8a3c20cb081d6a90962556da3124919cc4e5675e59ad31562af39299da02fb"
1893
- },
1894
- samples: [
1895
- {
1896
- gasUsed: "998146",
1897
- transactionHash: "0x97bc72692d241e2c344b912804f9939061db5ef59cf4bb23922d93812e382160",
1898
- blockNumber: "49",
1899
- blockHash: "0x2e09df4df84a1c25961386febe8404531bb5da274836d50cc15a26c91b433a98",
1900
- calldataBytes: 9540
1901
- },
1902
- {
1903
- gasUsed: "998134",
1904
- transactionHash: "0x26c5067b12c2bc4b694070784e6b19d4855efa6e77c2422f0c6b1567f061570a",
1905
- blockNumber: "49",
1906
- blockHash: "0xdd3f20520c09e001374cab58387e52c82446db053539e30dad28b0de679a333c",
1907
- calldataBytes: 9540
1908
- },
1909
- {
1910
- gasUsed: "998230",
1911
- transactionHash: "0x5dc09445a405150da1445c22f50d6dd10d8d428a6a3f41ee90db7d3574657e31",
1912
- blockNumber: "49",
1913
- blockHash: "0x5c8f8223a50d2c8d48188a2db28ffa33c1b150a2fb465e99db4430949db3664b",
1914
- calldataBytes: 9540
1915
- }
1916
- ]
1917
2561
  }
1918
2562
  ]
1919
2563
  }
@@ -1942,6 +2586,29 @@ function copyGasBenchmarks(profiles) {
1942
2586
  for (const p of copy) {
1943
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)
1944
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");
1945
2612
  for (const m of p.measurements) {
1946
2613
  if (!m.id || !m.samples.length || !["none", "caller", "signature"].includes(m.shape.funding) || typeof m.shape.permit !== "boolean")
1947
2614
  throw new Error("invalid gas benchmark measurement");
@@ -2021,11 +2688,20 @@ function estimateBenchmarkGas(plan, protocol, profiles) {
2021
2688
  );
2022
2689
  if (!request.deployment.runtimeCodeHash || !candidates.length)
2023
2690
  return { ...base, available: false, reason: "deployment-not-covered" };
2024
- for (const profile of candidates) {
2025
- const measurement = profile.measurements.find(
2691
+ const exact = candidates.flatMap(
2692
+ (profile) => profile.measurements.filter(
2026
2693
  (m) => shapeKeys.every((key) => m.shape[key] === request.shape[key]) && sameCircuit(m.circuit, request.circuit)
2027
- );
2028
- 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];
2029
2705
  const gas = measurement.samples.map((sample) => BigInt(sample.gasUsed));
2030
2706
  const count = BigInt(gas.length);
2031
2707
  return {
@@ -2055,14 +2731,20 @@ function estimateShapeGas(request, profiles = defaultProfiles) {
2055
2731
  const matching = measurements.filter(
2056
2732
  (measurement) => measurement.shape.kind === request.shape.kind && measurement.shape.target === request.shape.target && sameCircuit(measurement.circuit, request.circuit)
2057
2733
  );
2058
- const exact = matching.find(
2734
+ const exact = matching.filter(
2059
2735
  (measurement) => shapeKeys.every((key) => measurement.shape[key] === request.shape[key])
2060
2736
  );
2061
- if (exact) {
2062
- const gas = exact.samples.map((sample) => BigInt(sample.gasUsed));
2063
- const count = BigInt(gas.length);
2064
- 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) };
2065
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");
2066
2748
  const candidates = matching.length ? matching : measurements.filter(
2067
2749
  (measurement) => measurement.shape.kind === request.shape.kind && measurement.shape.target === request.shape.target
2068
2750
  );
@@ -2077,7 +2759,22 @@ function estimateShapeGas(request, profiles = defaultProfiles) {
2077
2759
  "deliveryBytes",
2078
2760
  ...!matching.length ? ["capacity"] : []
2079
2761
  ];
2080
- 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) => {
2081
2778
  let numerator = 1n;
2082
2779
  let denominator = 1n;
2083
2780
  for (const key of dimensions) {
@@ -2108,7 +2805,7 @@ function estimateGasReference(plan, protocol, profiles) {
2108
2805
 
2109
2806
  // src/session/operation-execution.ts
2110
2807
  var import_ethers6 = require("ethers");
2111
- var import_core3 = require("@invisi-labs/core");
2808
+ var import_core4 = require("@invisi-labs/core");
2112
2809
 
2113
2810
  // src/session/proof-integrity.ts
2114
2811
  var import_ethers5 = require("ethers");
@@ -2137,7 +2834,7 @@ async function authorizeOperation(plan, provider) {
2137
2834
  if (provider.walletIdentity !== plan.scope.walletIdentity)
2138
2835
  throw new Error("wallet authorization capability mismatch");
2139
2836
  const request = authorizationRequest(plan);
2140
- const digest = (0, import_core3.computeWalletAuthorizationDigest)(request);
2837
+ const digest = (0, import_core4.computeWalletAuthorizationDigest)(request);
2141
2838
  const signed = await provider.authorize(structuredClone(request));
2142
2839
  if (signed.walletIdentity !== plan.scope.walletIdentity || signed.digest !== digest)
2143
2840
  throw new Error("wallet authorization statement mismatch");
@@ -2221,11 +2918,11 @@ function operationPreview(plan, status) {
2221
2918
  }
2222
2919
 
2223
2920
  // src/session/Operation.ts
2224
- var import_core7 = require("@invisi-labs/core");
2921
+ var import_core8 = require("@invisi-labs/core");
2225
2922
  var import_protocol4 = require("@invisi-labs/protocol");
2226
2923
 
2227
2924
  // src/session/operation-confirmation.ts
2228
- var import_core6 = require("@invisi-labs/core");
2925
+ var import_core7 = require("@invisi-labs/core");
2229
2926
 
2230
2927
  // src/session/aggregate-receipt.ts
2231
2928
  var import_ethers7 = require("ethers");
@@ -2281,10 +2978,10 @@ function matchesAggregateTransaction(saved, transaction) {
2281
2978
  }
2282
2979
 
2283
2980
  // src/session/credit-values.ts
2284
- var import_core4 = require("@invisi-labs/core");
2981
+ var import_core5 = require("@invisi-labs/core");
2285
2982
  async function creditLeaf(state) {
2286
2983
  const n = state.note;
2287
- return (0, import_core4.computeCreditCommitment)(
2984
+ return (0, import_core5.computeCreditCommitment)(
2288
2985
  n.chainId,
2289
2986
  n.spenderWalletIdentity,
2290
2987
  n.ownerWalletIdentity,
@@ -2294,22 +2991,23 @@ async function creditLeaf(state) {
2294
2991
  n.amount,
2295
2992
  n.nonce,
2296
2993
  n.expiry,
2297
- await (0, import_core4.computeCreditSharedKeyHash)(n.creditSharedKey)
2994
+ await (0, import_core5.computeCreditSharedKeyHash)(n.creditSharedKey),
2995
+ n
2298
2996
  );
2299
2997
  }
2300
2998
 
2301
2999
  // src/session/membership.ts
2302
- var import_core5 = require("@invisi-labs/core");
3000
+ var import_core6 = require("@invisi-labs/core");
2303
3001
  async function verifyMembership(reader, context, block, input, proof) {
2304
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))
2305
3003
  throw new Error("membership context/root mismatch");
2306
3004
  let root = BigInt(input.commitment);
2307
3005
  for (let i = 0; i < 16; i++) {
2308
3006
  const sibling = proof.path[i];
2309
- if (typeof sibling !== "bigint" || sibling < 0n || sibling >= import_core5.FIELD_MODULUS)
3007
+ if (typeof sibling !== "bigint" || sibling < 0n || sibling >= import_core6.FIELD_MODULUS)
2310
3008
  throw new Error("noncanonical membership path");
2311
3009
  root = BigInt(
2312
- 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])
2313
3011
  );
2314
3012
  }
2315
3013
  if (root !== BigInt(proof.root))
@@ -2481,7 +3179,7 @@ async function confirmOperation(runtime, id, generation, hash2, signal) {
2481
3179
  if (credits.length) {
2482
3180
  const nullifiers = await Promise.all(
2483
3181
  credits.map(
2484
- async (record) => (0, import_core6.computeCreditNullifier)(
3182
+ async (record) => (0, import_core7.computeCreditNullifier)(
2485
3183
  plan.context.chainId,
2486
3184
  record.state.note.creditSharedKey,
2487
3185
  await creditLeaf(record.state)
@@ -2813,7 +3511,7 @@ var Operation = class _Operation {
2813
3511
  }
2814
3512
  const prover = this.#runtime.options.prover;
2815
3513
  if (!prover) {
2816
- throw new import_core7.MissingCapabilityError("prover");
3514
+ throw new import_core8.MissingCapabilityError("prover");
2817
3515
  }
2818
3516
  return this.stage(
2819
3517
  "proof",
@@ -2847,7 +3545,7 @@ var Operation = class _Operation {
2847
3545
  check6(p.kind === "shield" || this.#saved.proof, "proof must precede funding authorization");
2848
3546
  const signer = this.#runtime.options.fundingSigner;
2849
3547
  if (!signer) {
2850
- throw new import_core7.MissingCapabilityError("EVM funding signer");
3548
+ throw new import_core8.MissingCapabilityError("EVM funding signer");
2851
3549
  }
2852
3550
  check6(
2853
3551
  signer.address.toLowerCase() === p.funding.payer.toLowerCase(),
@@ -3038,7 +3736,7 @@ var Operation = class _Operation {
3038
3736
 
3039
3737
  // src/session/WalletSession.ts
3040
3738
  var import_ethers11 = require("ethers");
3041
- var import_core12 = require("@invisi-labs/core");
3739
+ var import_core13 = require("@invisi-labs/core");
3042
3740
 
3043
3741
  // src/session/transaction-preparation.ts
3044
3742
  var import_ethers10 = require("ethers");
@@ -3046,7 +3744,7 @@ var import_protocol7 = require("@invisi-labs/protocol");
3046
3744
 
3047
3745
  // src/session/prepare-common.ts
3048
3746
  var import_ethers8 = require("ethers");
3049
- var import_core8 = require("@invisi-labs/core");
3747
+ var import_core9 = require("@invisi-labs/core");
3050
3748
  var import_protocol5 = require("@invisi-labs/protocol");
3051
3749
 
3052
3750
  // src/session/selection.ts
@@ -3102,7 +3800,15 @@ var Preparation = class {
3102
3800
  throw new Error("canonical wallet checkpoint changed; resync required");
3103
3801
  }
3104
3802
  }
3105
- 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
+ };
3106
3812
  }
3107
3813
  async assertBlock(frame) {
3108
3814
  if ((await this.runtime.reader.getBlock(frame.block.number)).hash !== frame.block.hash) {
@@ -3143,11 +3849,12 @@ var Preparation = class {
3143
3849
  }
3144
3850
  async output(payment, context, change = false) {
3145
3851
  positiveAmount(payment.amount);
3146
- const recipient = await import_core8.ReceivingAddress.parse(payment.to).resolve(
3852
+ const recipient = await import_core9.ReceivingAddress.parse(payment.to).resolve(
3147
3853
  this.runtime.options.addressResolver
3148
3854
  );
3149
- const nonce = (0, import_core8.generateNonce)();
3150
- 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);
3151
3858
  const keys = recipient.getReceivingKeys();
3152
3859
  const note = {
3153
3860
  chainId: context.chainId,
@@ -3155,9 +3862,10 @@ var Preparation = class {
3155
3862
  tokenAddress: BigInt(context.tokenAddress),
3156
3863
  walletIdentity: recipient.walletIdentity,
3157
3864
  amount: payment.amount,
3865
+ ...memo.length === 0 ? {} : { memo },
3158
3866
  nonce
3159
3867
  };
3160
- const commitment = await (0, import_core8.computeNoteCommitment)(
3868
+ const commitment = await (0, import_core9.computeNoteCommitment)(
3161
3869
  context.chainId,
3162
3870
  identity,
3163
3871
  note.tokenAddress,
@@ -3171,20 +3879,20 @@ var Preparation = class {
3171
3879
  change,
3172
3880
  delivery: {
3173
3881
  ciphertext: (0, import_ethers8.hexlify)(
3174
- await (0, import_core8.encryptPrivateTransferNote)(keys.viewingPublicKey, note, {
3882
+ await (0, import_core9.encryptPrivateTransferNote)(keys.viewingPublicKey, note, {
3175
3883
  chainId: context.chainId,
3176
3884
  protocolAddress: note.protocolAddress,
3177
3885
  outputCommitment: commitment
3178
3886
  })
3179
3887
  ),
3180
- clue: (0, import_ethers8.hexlify)((0, import_core8.createClue)(keys.clueKey))
3888
+ clue: (0, import_ethers8.hexlify)((0, import_core9.createClue)(keys.clueKey))
3181
3889
  }
3182
3890
  };
3183
3891
  }
3184
3892
  async membership(input, frame) {
3185
3893
  const { options, reader } = this.runtime;
3186
3894
  if (!options.protocolRpc)
3187
- throw new import_core8.MissingCapabilityError("Protocol RPC membership provider");
3895
+ throw new import_core9.MissingCapabilityError("Protocol RPC membership provider");
3188
3896
  const root = this.#roots.get(input.treeId);
3189
3897
  const proof = await options.protocolRpc.getMembership(
3190
3898
  frame.context,
@@ -3231,9 +3939,9 @@ var Preparation = class {
3231
3939
  for (const input of selected) {
3232
3940
  const note = input.note;
3233
3941
  const c = frame.context;
3234
- 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)(
3235
3943
  c.chainId,
3236
- await (0, import_core8.computeNoteIdentity)(BigInt(note.walletIdentity), note.nonce),
3944
+ await (0, import_core9.computeNoteIdentity)(BigInt(note.walletIdentity), note.nonce),
3237
3945
  note.tokenAddress,
3238
3946
  note.amount
3239
3947
  ) !== input.commitment) {
@@ -3285,7 +3993,7 @@ function storedCandidates(inputs) {
3285
3993
 
3286
3994
  // src/session/prepare-credit.ts
3287
3995
  var import_ethers9 = require("ethers");
3288
- var import_core9 = require("@invisi-labs/core");
3996
+ var import_core10 = require("@invisi-labs/core");
3289
3997
  var import_protocol6 = require("@invisi-labs/protocol");
3290
3998
  var EMPTY = { ciphertext: "0x", clue: "0x" };
3291
3999
  var CreditPreparation = class {
@@ -3301,7 +4009,7 @@ var CreditPreparation = class {
3301
4009
  return value;
3302
4010
  }
3303
4011
  async seal(input, frame) {
3304
- const state = (0, import_core9.normalizeCreditDeliveryState)(input);
4012
+ const state = (0, import_core10.normalizeCreditDeliveryState)(input);
3305
4013
  const commitment = await creditLeaf(state);
3306
4014
  const context = {
3307
4015
  chainId: frame.context.chainId,
@@ -3313,9 +4021,9 @@ var CreditPreparation = class {
3313
4021
  const keys = role === "owner" ? state.ownerReceivingKeys : state.spenderReceivingKeys;
3314
4022
  return {
3315
4023
  ciphertext: (0, import_ethers9.hexlify)(
3316
- await (0, import_core9.encryptCreditNote)(keys.viewingPublicKey, state, { ...context, role })
4024
+ await (0, import_core10.encryptCreditNote)(keys.viewingPublicKey, state, { ...context, role })
3317
4025
  ),
3318
- clue: (0, import_ethers9.hexlify)((0, import_core9.createClue)(keys.clueKey))
4026
+ clue: (0, import_ethers9.hexlify)((0, import_core10.createClue)(keys.clueKey))
3319
4027
  };
3320
4028
  })
3321
4029
  );
@@ -3326,14 +4034,14 @@ var CreditPreparation = class {
3326
4034
  if (!stored || stored.spent !== "unspent" || stored.role !== role) {
3327
4035
  throw new Error(`confirmed unspent ${role} Credit is unavailable`);
3328
4036
  }
3329
- const state = (0, import_core9.normalizeCreditDeliveryState)(stored.state);
4037
+ const state = (0, import_core10.normalizeCreditDeliveryState)(stored.state);
3330
4038
  const n = state.note;
3331
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) {
3332
4040
  throw new Error("Credit role, commitment or deployment mismatch");
3333
4041
  }
3334
4042
  const proof = await this.#prepare.membership(stored, frame);
3335
4043
  const path = [...proof.path];
3336
- 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);
3337
4045
  await this.#prepare.assertUnspent([nullifier], frame);
3338
4046
  return {
3339
4047
  input: {
@@ -3370,7 +4078,7 @@ var CreditPreparation = class {
3370
4078
  positiveAmount(options.amount, 126);
3371
4079
  const frame = await this.#prepare.frame(options.deadline);
3372
4080
  const expiry = this.expiry(options.expiry, frame);
3373
- const spender = await import_core9.ReceivingAddress.parse(options.spender).resolve(
4081
+ const spender = await import_core10.ReceivingAddress.parse(options.spender).resolve(
3374
4082
  this.runtime.options.addressResolver
3375
4083
  );
3376
4084
  const owner = await this.runtime.options.wallet.getReceivingAddress().resolve(this.runtime.options.addressResolver);
@@ -3389,10 +4097,16 @@ var CreditPreparation = class {
3389
4097
  spenderWalletIdentity: spender.walletIdentity,
3390
4098
  ownerPayout: BigInt(ownerPayout),
3391
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
+ }),
3392
4105
  amount: options.amount,
4106
+ ...options.memo === void 0 ? {} : { memo: options.memo },
3393
4107
  expiry,
3394
- nonce: (0, import_core9.generateNonce)(),
3395
- creditSharedKey: (0, import_core9.generateCreditSharedKey)()
4108
+ nonce: (0, import_core10.generateNonce)(),
4109
+ creditSharedKey: (0, import_core10.generateCreditSharedKey)()
3396
4110
  },
3397
4111
  ownerReceivingKeys: owner.getReceivingKeys(),
3398
4112
  spenderReceivingKeys: spender.getReceivingKeys()
@@ -3481,7 +4195,19 @@ var CreditPreparation = class {
3481
4195
  }
3482
4196
  const amount = positiveAmount(old.note.amount + options.additionalAmount, 126);
3483
4197
  const output = await this.seal(
3484
- { ...old, note: { ...old.note, amount, expiry, nonce: (0, import_core9.generateNonce)() } },
4198
+ {
4199
+ ...old,
4200
+ note: {
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,
4205
+ amount,
4206
+ expiry,
4207
+ nonce: (0, import_core10.generateNonce)(),
4208
+ ...options.memo === void 0 ? {} : { memo: options.memo }
4209
+ }
4210
+ },
3485
4211
  frame
3486
4212
  );
3487
4213
  return this.creation(
@@ -3527,6 +4253,7 @@ var CreditPreparation = class {
3527
4253
  }
3528
4254
  sources.set(member.source.treeId, member.source.merkleRoot);
3529
4255
  amounts.push(amount);
4256
+ const usage = (0, import_core10.applyCreditDrawUsage)(n, amount, frame.block.timestamp);
3530
4257
  const remaining = n.amount - amount;
3531
4258
  if (remaining === 0n) {
3532
4259
  remainders.push((0, import_protocol6.word)(0n));
@@ -3546,8 +4273,10 @@ var CreditPreparation = class {
3546
4273
  ...state,
3547
4274
  note: {
3548
4275
  ...n,
4276
+ ...usage,
3549
4277
  amount: remaining,
3550
- nonce: await (0, import_core9.deriveRemainderNonce)(...args)
4278
+ ...options.credits[i].memo === void 0 ? {} : { memo: options.credits[i].memo },
4279
+ nonce: await (0, import_core10.deriveRemainderNonce)(...args)
3551
4280
  }
3552
4281
  },
3553
4282
  frame
@@ -3555,7 +4284,7 @@ var CreditPreparation = class {
3555
4284
  outputs.push(output);
3556
4285
  remainders.push(output.commitment);
3557
4286
  recoveryAmounts.push(
3558
- (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)
3559
4288
  );
3560
4289
  deliveries.push(...output.deliveries);
3561
4290
  }
@@ -3876,10 +4605,10 @@ async function refreshWallet(runtime, options) {
3876
4605
  }
3877
4606
 
3878
4607
  // src/session/WalletUpdater.ts
3879
- var import_core11 = require("@invisi-labs/core");
4608
+ var import_core12 = require("@invisi-labs/core");
3880
4609
 
3881
4610
  // src/session/inventory.ts
3882
- var import_core10 = require("@invisi-labs/core");
4611
+ var import_core11 = require("@invisi-labs/core");
3883
4612
  var CanonicalConflict = class extends Error {
3884
4613
  };
3885
4614
  var CreditMetadataMismatch = class extends Error {
@@ -3931,10 +4660,10 @@ var InventoryProcessor = class {
3931
4660
  }
3932
4661
  async creditNullifier(state) {
3933
4662
  const n = state.note;
3934
- return (0, import_core10.computeCreditNullifier)(
4663
+ return (0, import_core11.computeCreditNullifier)(
3935
4664
  n.chainId,
3936
4665
  n.creditSharedKey,
3937
- await (0, import_core10.computeCreditCommitment)(
4666
+ await (0, import_core11.computeCreditCommitment)(
3938
4667
  n.chainId,
3939
4668
  n.spenderWalletIdentity,
3940
4669
  n.ownerWalletIdentity,
@@ -3944,7 +4673,8 @@ var InventoryProcessor = class {
3944
4673
  n.amount,
3945
4674
  n.nonce,
3946
4675
  n.expiry,
3947
- await (0, import_core10.computeCreditSharedKeyHash)(n.creditSharedKey)
4676
+ await (0, import_core11.computeCreditSharedKeyHash)(n.creditSharedKey),
4677
+ n
3948
4678
  )
3949
4679
  );
3950
4680
  }
@@ -3991,6 +4721,9 @@ var InventoryProcessor = class {
3991
4721
  };
3992
4722
  for (const event of logs) {
3993
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");
3994
4727
  const args = event.args;
3995
4728
  const params = args.params;
3996
4729
  const indices = args.remainderLeafIndices;
@@ -4004,10 +4737,11 @@ var InventoryProcessor = class {
4004
4737
  previous.state.note.expiry === params.expiries[index2],
4005
4738
  "draw recovery expiry mismatch"
4006
4739
  );
4007
- const remainder = await (0, import_core10.recoverCreditRemainder)(
4740
+ const remainder = await (0, import_core11.recoverCreditRemainder)(
4008
4741
  context,
4009
4742
  previous.state.note,
4010
4743
  {
4744
+ timestamp: block.timestamp,
4011
4745
  creditNullifier: nullifier,
4012
4746
  remainderCommitment: params.remainderCommitments[index2],
4013
4747
  recoveryAmount: BigInt(params.recoveryAmounts[index2])
@@ -4016,6 +4750,10 @@ var InventoryProcessor = class {
4016
4750
  if (!remainder) {
4017
4751
  continue;
4018
4752
  }
4753
+ const child = foundByKey.get(
4754
+ params.remainderCommitments[index2] + ":" + previous.role
4755
+ );
4756
+ const memo = child?.state.note.memo;
4019
4757
  const record = {
4020
4758
  commitment: params.remainderCommitments[index2],
4021
4759
  treeId: BigInt(args.outputTreeId),
@@ -4024,7 +4762,13 @@ var InventoryProcessor = class {
4024
4762
  blockHash: event.blockHash,
4025
4763
  transactionHash: event.transactionHash,
4026
4764
  role: previous.role,
4027
- state: { ...clone(previous.state), note: remainder },
4765
+ state: {
4766
+ ...clone(previous.state),
4767
+ note: {
4768
+ ...remainder,
4769
+ ...memo === void 0 ? {} : { memo: (0, import_core11.encodeMemo)(memo) }
4770
+ }
4771
+ },
4028
4772
  receivingKeySource: { kind: "draw", commitment: previous.commitment },
4029
4773
  spent: "unknown"
4030
4774
  };
@@ -4101,7 +4845,7 @@ var WalletUpdater = class extends InventoryProcessor {
4101
4845
  }
4102
4846
  async run(batch, options) {
4103
4847
  const { reader, protocol, scope, store, viewing } = this.#options;
4104
- const nullifier = import_core11.NullifierCapability.fromIdentity(scope.walletIdentity);
4848
+ const nullifier = import_core12.NullifierCapability.fromIdentity(scope.walletIdentity);
4105
4849
  const { signal, reset } = options;
4106
4850
  signal?.throwIfAborted();
4107
4851
  const context = protocol.context;
@@ -4322,7 +5066,7 @@ var WalletSession = class {
4322
5066
  /** Delegate sending to ethers; managed operations additionally retain the resulting hash. */
4323
5067
  async sendTransaction(input, options = {}) {
4324
5068
  const signer = this.#options.signer;
4325
- if (!signer) throw new import_core12.MissingCapabilityError("ethers signer");
5069
+ if (!signer) throw new import_core13.MissingCapabilityError("ethers signer");
4326
5070
  const operation = input instanceof Operation ? input : void 0;
4327
5071
  if (operation && this.#sending.has(operation.id))
4328
5072
  throw new Error("operation is already being sent by this session");
@@ -4330,12 +5074,12 @@ var WalletSession = class {
4330
5074
  const overrides = { ...options };
4331
5075
  const plain = operation ? void 0 : { ...input };
4332
5076
  try {
4333
- if (!signer.provider) throw new import_core12.MissingCapabilityError("connected ethers signer");
5077
+ if (!signer.provider) throw new import_core13.MissingCapabilityError("connected ethers signer");
4334
5078
  if ((await signer.provider.getNetwork()).chainId !== this.protocol.context.chainId) {
4335
5079
  throw new Error("signer-provider session chain mismatch");
4336
5080
  }
4337
5081
  if (operation) {
4338
- if (!this.#options.store) throw new import_core12.MissingCapabilityError("wallet store");
5082
+ if (!this.#options.store) throw new import_core13.MissingCapabilityError("wallet store");
4339
5083
  const state = await this.#options.store.readSnapshot(this.scope);
4340
5084
  if (!state.operations[operation.id])
4341
5085
  throw new Error("operation does not belong to this wallet session");
@@ -4366,10 +5110,10 @@ var WalletSession = class {
4366
5110
  runtime(tokenAddress) {
4367
5111
  const options = this.#options;
4368
5112
  if (!options.store) {
4369
- throw new import_core12.MissingCapabilityError("wallet store");
5113
+ throw new import_core13.MissingCapabilityError("wallet store");
4370
5114
  }
4371
5115
  if (!options.chainReader) {
4372
- throw new import_core12.MissingCapabilityError("chain reader");
5116
+ throw new import_core13.MissingCapabilityError("chain reader");
4373
5117
  }
4374
5118
  return {
4375
5119
  options: { ...options, protocol: options.protocol.forToken(tokenAddress) },
@@ -4383,7 +5127,7 @@ var WalletSession = class {
4383
5127
  if (this.#updater) return this.#updater;
4384
5128
  const options = this.#options;
4385
5129
  if (!options.store || !options.chainReader || !options.protocolRpc)
4386
- 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");
4387
5131
  const viewing = options.viewing ?? options.wallet.getViewer();
4388
5132
  const receivingAddress = options.wallet.getReceivingAddress();
4389
5133
  const receivingKeys = receivingAddress.kind === "long" ? receivingAddress.getReceivingKeys() : void 0;
@@ -4401,7 +5145,7 @@ var WalletSession = class {
4401
5145
  async balance(tokenAddress) {
4402
5146
  const store = this.#options.store;
4403
5147
  if (!store) {
4404
- throw new import_core12.MissingCapabilityError("wallet store");
5148
+ throw new import_core13.MissingCapabilityError("wallet store");
4405
5149
  }
4406
5150
  return walletBalance(await store.readSnapshot(this.scope), (0, import_ethers11.getAddress)(tokenAddress));
4407
5151
  }
@@ -4409,8 +5153,8 @@ var WalletSession = class {
4409
5153
  async refresh(options) {
4410
5154
  const provider = this.#options.protocolRpc;
4411
5155
  const reader = this.#options.chainReader;
4412
- if (!reader) throw new import_core12.MissingCapabilityError("chain reader");
4413
- 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");
4414
5158
  const updater = this.updater();
4415
5159
  const request = {
4416
5160
  ...options,
@@ -4469,7 +5213,7 @@ var WalletSession = class {
4469
5213
  }
4470
5214
  async resume(operationId) {
4471
5215
  const store = this.#options.store;
4472
- if (!store) throw new import_core12.MissingCapabilityError("wallet store");
5216
+ if (!store) throw new import_core13.MissingCapabilityError("wallet store");
4473
5217
  const state = await store.readSnapshot(this.scope);
4474
5218
  const saved = state.operations[operationId]?.payload;
4475
5219
  if (!saved?.plan) throw new Error("operation not found");