@arcanetech/privacy-sdk-stellar 0.5.1 → 0.5.2

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/node.d.ts CHANGED
@@ -198,14 +198,15 @@ interface StellarTransactEnvironment {
198
198
  network: StellarNetworkConfig;
199
199
  /**
200
200
  * Nonce (persistent storage key) of the pool's `ZkConfig` entry this
201
- * environment's proofs/circuit shape target. Defaults to `2n` (Commitment
202
- * V2, 95 public signals) when omitted. Nonce `0` is the retired 93-signal
203
- * layout and must be passed explicitly.
201
+ * environment's proofs/circuit shape target. Defaults to `3n` (bundled 2×2
202
+ * binding layout) when omitted. Also bundled: `7n` (6×6). The value must
203
+ * match the on-chain pool config or bootstrap/execute fails with
204
+ * `no zk circuit configured for nonce …`.
204
205
  */
205
206
  zkConfigNonce?: bigint;
206
207
  /**
207
- * Optional nonce-keyed circuit map. Defaults to the SDK bundled 2×2 (nonce 2)
208
- * and 6×6 (nonce 6) schemes. URL fields are only for a custom/dev circuit.
208
+ * Optional nonce-keyed circuit map. Defaults to the SDK bundled 2×2 (nonce 3)
209
+ * and 6×6 (nonce 7) schemes. URL fields are only for a custom/dev circuit.
209
210
  */
210
211
  zkCircuits?: Record<string, StellarZkCircuitDefinition>;
211
212
  /**
package/dist/node.js CHANGED
@@ -806,6 +806,7 @@ function buildPoolTransactionAuditParameters(input) {
806
806
  input.nAuditSlots
807
807
  );
808
808
  }
809
+ var DECIMAL_APPLICATION_ID = /^\d+$/u;
809
810
  function resolvePoolApplicationId(applicationId) {
810
811
  const trimmed = applicationId?.trim();
811
812
  if (!trimmed) {
@@ -813,6 +814,11 @@ function resolvePoolApplicationId(applicationId) {
813
814
  "Privacy pool applicationId is required. Pass it in client factory config."
814
815
  );
815
816
  }
817
+ if (!DECIMAL_APPLICATION_ID.test(trimmed)) {
818
+ throw new Error(
819
+ "Privacy pool applicationId must be association.audit_id (decimal Fr), not a UUID or foreignId."
820
+ );
821
+ }
816
822
  return trimmed;
817
823
  }
818
824
 
@@ -1586,92 +1592,167 @@ function getPrivacyPoolService() {
1586
1592
  }
1587
1593
 
1588
1594
  // src/transact/merkle/fetch-contract.ts
1595
+ import { Buffer as Buffer12 } from "buffer";
1596
+
1597
+ // src/transact/merkle/state-port.ts
1598
+ function poolMerkleStateToCachedView(state) {
1599
+ return {
1600
+ commitments: state.commitments,
1601
+ updatedAt: state.updatedAt,
1602
+ merkleRootHex: state.merkleRootHex
1603
+ };
1604
+ }
1605
+
1606
+ // src/transact/merkle/read-tree-leaves.ts
1607
+ import { Address, xdr } from "@stellar/stellar-sdk";
1589
1608
  import { Buffer as Buffer11 } from "buffer";
1590
1609
 
1591
1610
  // src/transact/merkle/encoding.ts
1592
1611
  import "buffer";
1593
1612
  var FR_ORDER = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n;
1594
- function bufferToDecimal(buf) {
1613
+ function commitmentBufferToDecimal(buf) {
1595
1614
  const hex = buf.toString("hex");
1596
1615
  const bigintFromHex = BigInt(`0x${hex}`);
1597
1616
  const reduced = bigintFromHex % FR_ORDER;
1598
1617
  return reduced.toString();
1599
1618
  }
1600
- function commitmentsBuffersToDecimal(buffers) {
1601
- return buffers.map((bufferRow) => bufferToDecimal(bufferRow));
1602
- }
1603
-
1604
- // src/transact/merkle/state-port.ts
1605
- function poolMerkleStateToCachedView(state) {
1606
- return {
1607
- commitments: state.commitments,
1608
- updatedAt: state.updatedAt,
1609
- merkleRootHex: state.merkleRootHex
1610
- };
1611
- }
1612
1619
 
1613
- // src/transact/merkle/fetch-contract.ts
1614
- function normalizeCommitmentBuffers(rawBuffers) {
1615
- return rawBuffers.map(
1616
- (bufferRow) => Buffer11.isBuffer(bufferRow) ? bufferRow : Buffer11.from(bufferRow)
1620
+ // src/transact/merkle/read-tree-leaves.ts
1621
+ var TREE_LEAF_LEDGER_BATCH_SIZE = 100;
1622
+ function treeLeafLedgerKey(contractId, leafIndex) {
1623
+ return xdr.LedgerKey.contractData(
1624
+ new xdr.LedgerKeyContractData({
1625
+ contract: new Address(contractId).toScAddress(),
1626
+ key: treeLeafKeyScValue(leafIndex),
1627
+ durability: xdr.ContractDataDurability.persistent()
1628
+ })
1617
1629
  );
1618
1630
  }
1619
- function mergeContractMerkleWithCache(parameters) {
1620
- const cachedCount = parameters.cachedState?.commitments.length ?? 0;
1621
- const shouldPreferContract = parameters.contractCount > cachedCount || !parameters.cachedState || cachedCount === 0;
1622
- if (shouldPreferContract) {
1623
- const updatedAt = Date.now();
1624
- void parameters.poolMerkleState?.set({
1625
- poolContract: parameters.poolContractId,
1626
- commitments: parameters.contractCommitments,
1627
- commitmentCount: parameters.contractCount,
1628
- merkleRootHex: parameters.merkleRootHex,
1629
- updatedAt
1630
- });
1631
- return {
1632
- commitments: parameters.contractCommitments,
1633
- updatedAt,
1634
- merkleRootHex: parameters.merkleRootHex,
1635
- commitmentCount: parameters.contractCount
1636
- };
1631
+ function treeLeafKeyScValue(leafIndex) {
1632
+ return xdr.ScVal.scvVec([xdr.ScVal.scvSymbol("Leaf"), xdr.ScVal.scvU32(leafIndex)]);
1633
+ }
1634
+ function leafIndexFromContractDataKey(key) {
1635
+ if (key.switch() !== xdr.ScValType.scvVec()) {
1636
+ return void 0;
1637
1637
  }
1638
- return {
1639
- commitments: parameters.cachedState.commitments,
1640
- updatedAt: parameters.cachedState.updatedAt,
1641
- merkleRootHex: parameters.cachedState.merkleRootHex ?? parameters.merkleRootHex,
1642
- commitmentCount: parameters.cachedState.commitments.length
1643
- };
1638
+ const fields = key.vec();
1639
+ if (!fields || fields.length !== 2) {
1640
+ return void 0;
1641
+ }
1642
+ const [tag, indexValue] = fields;
1643
+ if (!tag || tag.switch() !== xdr.ScValType.scvSymbol()) {
1644
+ return void 0;
1645
+ }
1646
+ if (tag.sym().toString() !== "Leaf") {
1647
+ return void 0;
1648
+ }
1649
+ if (!indexValue || indexValue.switch() !== xdr.ScValType.scvU32()) {
1650
+ return void 0;
1651
+ }
1652
+ return indexValue.u32();
1644
1653
  }
1645
- async function readCachedPoolMerkleView(poolMerkleState, poolContractId) {
1646
- if (!poolMerkleState) {
1654
+ function commitmentBytesFromContractDataValue(value) {
1655
+ if (value.switch() !== xdr.ScValType.scvBytes()) {
1647
1656
  return void 0;
1648
1657
  }
1649
- const cached = await poolMerkleState.get(poolContractId);
1650
- return cached ? poolMerkleStateToCachedView(cached) : void 0;
1658
+ return Buffer11.from(value.bytes());
1659
+ }
1660
+ async function readTreeLeafCommitments(input) {
1661
+ if (input.startIndex >= input.endIndex) {
1662
+ return [];
1663
+ }
1664
+ const byIndex = await readLeafBuffersByIndex(input);
1665
+ return decimalCommitmentsInRange(byIndex, input.startIndex, input.endIndex);
1666
+ }
1667
+ async function readLeafBuffersByIndex(input) {
1668
+ const keys = ledgerKeysForRange(input.contractId, input.startIndex, input.endIndex);
1669
+ const byIndex = /* @__PURE__ */ new Map();
1670
+ for (const batch of chunkLedgerKeys(keys, TREE_LEAF_LEDGER_BATCH_SIZE)) {
1671
+ const response = await input.reader.getLedgerEntries(...batch);
1672
+ collectLeafBuffers(response.entries, byIndex);
1673
+ }
1674
+ return byIndex;
1675
+ }
1676
+ function ledgerKeysForRange(contractId, startIndex, endIndex) {
1677
+ const keys = [];
1678
+ for (let leafIndex = startIndex; leafIndex < endIndex; leafIndex += 1) {
1679
+ keys.push(treeLeafLedgerKey(contractId, leafIndex));
1680
+ }
1681
+ return keys;
1682
+ }
1683
+ function chunkLedgerKeys(keys, batchSize) {
1684
+ const batches = [];
1685
+ for (let offset = 0; offset < keys.length; offset += batchSize) {
1686
+ batches.push(keys.slice(offset, offset + batchSize));
1687
+ }
1688
+ return batches;
1689
+ }
1690
+ function collectLeafBuffers(entries, byIndex) {
1691
+ for (const entry of entries) {
1692
+ const contractData = entry.val.contractData();
1693
+ const leafIndex = leafIndexFromContractDataKey(contractData.key());
1694
+ const bytes = commitmentBytesFromContractDataValue(contractData.val());
1695
+ if (leafIndex === void 0 || !bytes) {
1696
+ continue;
1697
+ }
1698
+ byIndex.set(leafIndex, bytes);
1699
+ }
1700
+ }
1701
+ function decimalCommitmentsInRange(byIndex, startIndex, endIndex) {
1702
+ const commitments = [];
1703
+ for (let leafIndex = startIndex; leafIndex < endIndex; leafIndex += 1) {
1704
+ const bytes = byIndex.get(leafIndex);
1705
+ if (!bytes) {
1706
+ throw new Error(`Missing Merkle leaf ${String(leafIndex)} in pool storage.`);
1707
+ }
1708
+ commitments.push(commitmentBufferToDecimal(bytes));
1709
+ }
1710
+ return commitments;
1711
+ }
1712
+
1713
+ // src/transact/merkle/reuse-cached-commitments.ts
1714
+ function completeCacheRootMatches(cachedState, merkleRootHex) {
1715
+ const cachedRoot = cachedState?.merkleRootHex;
1716
+ if (cachedRoot === void 0 || cachedRoot === "") {
1717
+ return true;
1718
+ }
1719
+ return cachedRoot === merkleRootHex;
1720
+ }
1721
+ function reuseCachedCommitments(input) {
1722
+ const cachedCommitments = input.cachedState?.commitments ?? [];
1723
+ if (cachedCommitments.length === 0) {
1724
+ return [];
1725
+ }
1726
+ if (cachedCommitments.length > input.onChainCount) {
1727
+ return [];
1728
+ }
1729
+ if (cachedCommitments.length === input.onChainCount) {
1730
+ return completeCacheRootMatches(input.cachedState, input.merkleRootHex) ? cachedCommitments : [];
1731
+ }
1732
+ return cachedCommitments;
1651
1733
  }
1734
+
1735
+ // src/transact/merkle/fetch-contract.ts
1652
1736
  async function fetchAndMergeMerkleState(parameters) {
1653
- const client = readPoolClientFactory(parameters.transactEnvironment)({
1654
- contractId: parameters.poolContractId,
1655
- walletPublicKey: parameters.walletPublicKey,
1656
- networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1657
- sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1658
- });
1659
- const commitmentsRead = await client.get_commitments();
1660
- const rawBuffers = commitmentsRead.result;
1661
- const buffers = normalizeCommitmentBuffers(rawBuffers);
1662
- const contractCommitments = commitmentsBuffersToDecimal(buffers);
1663
- const contractCount = contractCommitments.length;
1737
+ const client = createPoolClient(parameters);
1738
+ const countRead = await client.get_commitment_count();
1739
+ const onChainCount = requireCommitmentCount(countRead.result);
1664
1740
  const rootRead = await client.get_merkle_root();
1665
- const merkleRootBuffer = rootRead.result;
1666
- const merkleRootHex = Buffer11.from(merkleRootBuffer).toString("hex");
1741
+ const merkleRootHex = merkleRootToHex(rootRead.result);
1667
1742
  const cachedState = await readCachedPoolMerkleView(
1668
1743
  parameters.poolMerkleState,
1669
1744
  parameters.poolContractId
1670
1745
  );
1671
- return mergeContractMerkleWithCache({
1746
+ const commitments = await loadCommitments({
1747
+ cachedState,
1748
+ onChainCount,
1749
+ merkleRootHex,
1750
+ rpcUrl: parameters.transactEnvironment.network.rpcUrl,
1751
+ contractId: parameters.poolContractId
1752
+ });
1753
+ return persistFetchedMerkleState({
1672
1754
  poolContractId: parameters.poolContractId,
1673
- contractCommitments,
1674
- contractCount,
1755
+ commitments,
1675
1756
  merkleRootHex,
1676
1757
  cachedState,
1677
1758
  ...parameters.poolMerkleState ? { poolMerkleState: parameters.poolMerkleState } : {}
@@ -1685,19 +1766,14 @@ async function readLeafEphemeralHex(parameters) {
1685
1766
  if (cached?.xHex && cached.yHex) {
1686
1767
  return { xHex: cached.xHex, yHex: cached.yHex };
1687
1768
  }
1688
- const client = readPoolClientFactory(parameters.transactEnvironment)({
1689
- contractId: parameters.poolContractId,
1690
- walletPublicKey: parameters.walletPublicKey,
1691
- networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1692
- sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1693
- });
1769
+ const client = createPoolClient(parameters);
1694
1770
  const read = await client.get_leaf_ephemeral({ leaf_index: parameters.leafIndex });
1695
1771
  const coords = read.result;
1696
1772
  if (!coords?.x || !coords?.y) {
1697
1773
  throw new Error("Missing leaf ephemeral key on contract");
1698
1774
  }
1699
- const xHex = Buffer11.from(coords.x).toString("hex");
1700
- const yHex = Buffer11.from(coords.y).toString("hex");
1775
+ const xHex = Buffer12.from(coords.x).toString("hex");
1776
+ const yHex = Buffer12.from(coords.y).toString("hex");
1701
1777
  await parameters.leafEphemeral?.set({
1702
1778
  poolContract: parameters.poolContractId,
1703
1779
  leafIndex: parameters.leafIndex,
@@ -1707,6 +1783,84 @@ async function readLeafEphemeralHex(parameters) {
1707
1783
  });
1708
1784
  return { xHex, yHex };
1709
1785
  }
1786
+ function createPoolClient(parameters) {
1787
+ return readPoolClientFactory(parameters.transactEnvironment)({
1788
+ contractId: parameters.poolContractId,
1789
+ walletPublicKey: parameters.walletPublicKey,
1790
+ networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1791
+ sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1792
+ });
1793
+ }
1794
+ function requireCommitmentCount(result) {
1795
+ if (typeof result === "number" && Number.isInteger(result) && result >= 0) {
1796
+ return result;
1797
+ }
1798
+ throw new Error("Pool commitment count is not a non-negative integer.");
1799
+ }
1800
+ function merkleRootToHex(root) {
1801
+ return Buffer12.from(root).toString("hex");
1802
+ }
1803
+ async function readCachedPoolMerkleView(poolMerkleState, poolContractId) {
1804
+ if (!poolMerkleState) {
1805
+ return void 0;
1806
+ }
1807
+ const cached = await poolMerkleState.get(poolContractId);
1808
+ return cached ? poolMerkleStateToCachedView(cached) : void 0;
1809
+ }
1810
+ async function loadCommitments(input) {
1811
+ const reused = reuseCachedCommitments({
1812
+ cachedState: input.cachedState,
1813
+ onChainCount: input.onChainCount,
1814
+ merkleRootHex: input.merkleRootHex
1815
+ });
1816
+ if (reused.length === input.onChainCount) {
1817
+ return reused;
1818
+ }
1819
+ const fetched = await readTreeLeafCommitments({
1820
+ reader: createStellarRpcServer(input.rpcUrl),
1821
+ contractId: input.contractId,
1822
+ startIndex: reused.length,
1823
+ endIndex: input.onChainCount
1824
+ });
1825
+ return [...reused, ...fetched];
1826
+ }
1827
+ async function persistFetchedMerkleState(input) {
1828
+ const cachedState = input.cachedState;
1829
+ if (cachedState && cachedMerkleUnchanged(cachedState, input.commitments, input.merkleRootHex)) {
1830
+ return viewFromCachedMerkle(cachedState, input.merkleRootHex);
1831
+ }
1832
+ const updatedAt = Date.now();
1833
+ await input.poolMerkleState?.set({
1834
+ poolContract: input.poolContractId,
1835
+ commitments: input.commitments,
1836
+ commitmentCount: input.commitments.length,
1837
+ merkleRootHex: input.merkleRootHex,
1838
+ updatedAt
1839
+ });
1840
+ return {
1841
+ commitments: input.commitments,
1842
+ updatedAt,
1843
+ merkleRootHex: input.merkleRootHex,
1844
+ commitmentCount: input.commitments.length
1845
+ };
1846
+ }
1847
+ function viewFromCachedMerkle(cachedState, merkleRootHex) {
1848
+ return {
1849
+ commitments: cachedState.commitments,
1850
+ updatedAt: cachedState.updatedAt,
1851
+ merkleRootHex: cachedState.merkleRootHex ?? merkleRootHex,
1852
+ commitmentCount: cachedState.commitments.length
1853
+ };
1854
+ }
1855
+ function cachedMerkleUnchanged(cachedState, commitments, merkleRootHex) {
1856
+ if (!cachedState) {
1857
+ return false;
1858
+ }
1859
+ if ((cachedState.merkleRootHex ?? merkleRootHex) !== merkleRootHex) {
1860
+ return false;
1861
+ }
1862
+ return cachedState.commitments.join(",") === commitments.join(",");
1863
+ }
1710
1864
 
1711
1865
  // src/transact/engine/prepare/shared.ts
1712
1866
  async function resolveTokenContractId2(environment, assetId) {
@@ -4104,7 +4258,7 @@ function createStellarStorageAdapterFromState(state) {
4104
4258
  }
4105
4259
 
4106
4260
  // src/contracts/registry/registry-domain-service.ts
4107
- import { Buffer as Buffer12 } from "buffer";
4261
+ import { Buffer as Buffer13 } from "buffer";
4108
4262
 
4109
4263
  // src/transact/submit/ttl-preflight.ts
4110
4264
  function getNested(source, path) {
@@ -4153,11 +4307,11 @@ async function runTtlPreflight(assembledTransaction) {
4153
4307
  // src/contracts/registry/registry-domain-service.ts
4154
4308
  var COORDINATE_HEX_LENGTH = 64;
4155
4309
  function readCoordinateBytes(value) {
4156
- if (value instanceof Buffer12) {
4310
+ if (value instanceof Buffer13) {
4157
4311
  return value;
4158
4312
  }
4159
4313
  if (value instanceof Uint8Array) {
4160
- return Buffer12.from(value);
4314
+ return Buffer13.from(value);
4161
4315
  }
4162
4316
  return void 0;
4163
4317
  }
@@ -4196,8 +4350,8 @@ function parseRegistryLookupRecord(result) {
4196
4350
  return parseOptionSomeRecord(result);
4197
4351
  }
4198
4352
  function recordToLookupResult(record) {
4199
- const publicKeyXHex = Buffer12.from(record.public_key_x).toString("hex");
4200
- const publicKeyYHex = Buffer12.from(record.public_key_y).toString("hex");
4353
+ const publicKeyXHex = Buffer13.from(record.public_key_x).toString("hex");
4354
+ const publicKeyYHex = Buffer13.from(record.public_key_y).toString("hex");
4201
4355
  return {
4202
4356
  owner: record.owner,
4203
4357
  status: "registered",
@@ -4240,8 +4394,8 @@ async function registerPrivateAddressOnChain(input) {
4240
4394
  });
4241
4395
  const assembled = await client.register_private_address({
4242
4396
  owner: input.owner.trim(),
4243
- public_key_x: Buffer12.from(decoded.x.padStart(COORDINATE_HEX_LENGTH, "0"), "hex"),
4244
- public_key_y: Buffer12.from(decoded.y.padStart(COORDINATE_HEX_LENGTH, "0"), "hex")
4397
+ public_key_x: Buffer13.from(decoded.x.padStart(COORDINATE_HEX_LENGTH, "0"), "hex"),
4398
+ public_key_y: Buffer13.from(decoded.y.padStart(COORDINATE_HEX_LENGTH, "0"), "hex")
4245
4399
  });
4246
4400
  await runTtlPreflight(assembled);
4247
4401
  const sent = await assembled.signAndSend();
@@ -4256,7 +4410,7 @@ async function registerPrivateAddressOnChain(input) {
4256
4410
  import { StrKey as StrKey5 } from "@stellar/stellar-sdk";
4257
4411
 
4258
4412
  // src/transact/escrow/derived-escrow-recipient.ts
4259
- import { Buffer as Buffer13 } from "buffer";
4413
+ import { Buffer as Buffer14 } from "buffer";
4260
4414
  import { StrKey as StrKey4 } from "@stellar/stellar-sdk";
4261
4415
  import {
4262
4416
  derivedEscrowKey,
@@ -4266,7 +4420,7 @@ import {
4266
4420
  var COORDINATE_HEX_LENGTH2 = 64;
4267
4421
  function stellarAccountToFieldLimbs(stellarAddress) {
4268
4422
  const pkRaw = StrKey4.decodeEd25519PublicKey(stellarAddress.trim());
4269
- const pkHex = Buffer13.from(pkRaw).toString("hex");
4423
+ const pkHex = Buffer14.from(pkRaw).toString("hex");
4270
4424
  const { hi, lo } = ed25519PubkeyPayloadHexToWithdrawFrDecimals2(pkHex);
4271
4425
  return { recipientHi: hi, recipientLo: lo };
4272
4426
  }
@@ -4351,7 +4505,7 @@ async function resolveTransferRecipientFromChain(input) {
4351
4505
  import { Api } from "@stellar/stellar-sdk/rpc";
4352
4506
 
4353
4507
  // src/rpc/soroban-transaction-meta.ts
4354
- import { Address, StrKey as StrKey6 } from "@stellar/stellar-sdk";
4508
+ import { Address as Address2, StrKey as StrKey6 } from "@stellar/stellar-sdk";
4355
4509
  var BIGINT_SHIFT_64 = 64n;
4356
4510
  var TRANSACTION_META_SWITCH_SOROBAN_V3 = 3;
4357
4511
  var TRANSACTION_META_SWITCH_SOROBAN_V4 = 4;
@@ -4451,8 +4605,8 @@ function transferPartyAddressesFromTopics(topics) {
4451
4605
  return void 0;
4452
4606
  }
4453
4607
  return {
4454
- from: Address.fromScVal(fromTopic).toString(),
4455
- to: Address.fromScVal(toTopic).toString()
4608
+ from: Address2.fromScVal(fromTopic).toString(),
4609
+ to: Address2.fromScVal(toTopic).toString()
4456
4610
  };
4457
4611
  } catch {
4458
4612
  return void 0;
@@ -6223,20 +6377,20 @@ async function waitForKytRegistration(parameters) {
6223
6377
  }
6224
6378
 
6225
6379
  // src/transact/kyt/passage/submit.ts
6226
- import { Buffer as Buffer14 } from "buffer";
6227
- import { Operation, TransactionBuilder, rpc as rpc3, xdr as xdr2 } from "@stellar/stellar-sdk";
6380
+ import { Buffer as Buffer15 } from "buffer";
6381
+ import { Operation, TransactionBuilder, rpc as rpc3, xdr as xdr3 } from "@stellar/stellar-sdk";
6228
6382
  var KYT_REGISTER_FEE_STROOPS = "1000000";
6229
6383
  var KYT_REGISTER_TIMEOUT_SECONDS = 300;
6230
6384
  function passageIdToScValue(passageId) {
6231
- return xdr2.ScVal.scvBytes(Buffer14.from(passageId.replace(/^0x/, ""), "hex"));
6385
+ return xdr3.ScVal.scvBytes(Buffer15.from(passageId.replace(/^0x/, ""), "hex"));
6232
6386
  }
6233
6387
  function approvalSignatureToBytes(signature) {
6234
6388
  const clean = signature.trim();
6235
- return /^(0x)?[0-9a-fA-F]{128}$/.test(clean) ? Buffer14.from(clean.replace(/^0x/i, ""), "hex") : Buffer14.from(clean, "base64");
6389
+ return /^(0x)?[0-9a-fA-F]{128}$/.test(clean) ? Buffer15.from(clean.replace(/^0x/i, ""), "hex") : Buffer15.from(clean, "base64");
6236
6390
  }
6237
6391
  function signatureToScValue(signature) {
6238
6392
  const bytes = approvalSignatureToBytes(signature);
6239
- return xdr2.ScVal.scvBytes(bytes);
6393
+ return xdr3.ScVal.scvBytes(bytes);
6240
6394
  }
6241
6395
  async function registerKytPassage(parameters) {
6242
6396
  const signTransaction = parameters.transactEnvironment.signTransaction;
@@ -6257,7 +6411,7 @@ async function registerKytPassage(parameters) {
6257
6411
  function: "register_passage",
6258
6412
  args: [
6259
6413
  passageIdToScValue(parameters.approval.passageId),
6260
- xdr2.ScVal.scvU32(parameters.approval.expiresAtLedger),
6414
+ xdr3.ScVal.scvU32(parameters.approval.expiresAtLedger),
6261
6415
  signatureToScValue(parameters.approval.signature)
6262
6416
  ]
6263
6417
  })
@@ -6382,12 +6536,12 @@ async function requestKytPassageForPoolInteraction(input) {
6382
6536
 
6383
6537
  // src/transact/submit/zk-config-ttl.ts
6384
6538
  import {
6385
- Address as Address2,
6539
+ Address as Address3,
6386
6540
  Operation as Operation2,
6387
6541
  SorobanDataBuilder,
6388
6542
  TransactionBuilder as TransactionBuilder2,
6389
6543
  rpc as rpc4,
6390
- xdr as xdr3
6544
+ xdr as xdr4
6391
6545
  } from "@stellar/stellar-sdk";
6392
6546
  var ZK_CONFIG_TTL_THRESHOLD_LEDGERS = 1e5;
6393
6547
  var ZK_CONFIG_TTL_EXTEND_TO_LEDGERS = 5e5;
@@ -6411,15 +6565,15 @@ async function waitForExtendFootprintTtlConfirmation(parameters) {
6411
6565
  throw new Error("ZK config TTL extension was not confirmed in time");
6412
6566
  }
6413
6567
  function zkConfigLedgerKey(contractId, nonce) {
6414
- const configKeyScValue = xdr3.ScVal.scvVec([
6415
- xdr3.ScVal.scvSymbol("Config"),
6416
- xdr3.ScVal.scvU64(xdr3.Uint64.fromString(nonce.toString()))
6568
+ const configKeyScValue = xdr4.ScVal.scvVec([
6569
+ xdr4.ScVal.scvSymbol("Config"),
6570
+ xdr4.ScVal.scvU64(xdr4.Uint64.fromString(nonce.toString()))
6417
6571
  ]);
6418
- return xdr3.LedgerKey.contractData(
6419
- new xdr3.LedgerKeyContractData({
6420
- contract: new Address2(contractId).toScAddress(),
6572
+ return xdr4.LedgerKey.contractData(
6573
+ new xdr4.LedgerKeyContractData({
6574
+ contract: new Address3(contractId).toScAddress(),
6421
6575
  key: configKeyScValue,
6422
- durability: xdr3.ContractDataDurability.persistent()
6576
+ durability: xdr4.ContractDataDurability.persistent()
6423
6577
  })
6424
6578
  );
6425
6579
  }
@@ -6484,7 +6638,7 @@ async function extendZkConfigTtlIfNeeded(parameters) {
6484
6638
  }
6485
6639
 
6486
6640
  // src/transact/submit/pool-transact.ts
6487
- import { Buffer as Buffer15 } from "buffer";
6641
+ import { Buffer as Buffer16 } from "buffer";
6488
6642
  async function submitPoolTransact(parameters) {
6489
6643
  await extendZkConfigTtlIfNeeded({
6490
6644
  sorobanRpcUrl: parameters.sorobanRpcUrl,
@@ -6497,9 +6651,9 @@ async function submitPoolTransact(parameters) {
6497
6651
  const assembledTransaction = await parameters.contractClient.transact({
6498
6652
  from: parameters.from,
6499
6653
  nonce: parameters.nonce,
6500
- proof_bytes: Buffer15.from(parameters.proofHex.replace(/^0x/iu, ""), "hex"),
6501
- pub_signals_bytes: Buffer15.from(parameters.publicHex.replace(/^0x/iu, ""), "hex"),
6502
- ciphertext_bytes: Buffer15.from(
6654
+ proof_bytes: Buffer16.from(parameters.proofHex.replace(/^0x/iu, ""), "hex"),
6655
+ pub_signals_bytes: Buffer16.from(parameters.publicHex.replace(/^0x/iu, ""), "hex"),
6656
+ ciphertext_bytes: Buffer16.from(
6503
6657
  (parameters.ciphertextHex ?? "").replace(/^0x/iu, ""),
6504
6658
  "hex"
6505
6659
  ),