@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/index.d.ts CHANGED
@@ -231,14 +231,15 @@ interface StellarTransactEnvironment {
231
231
  network: StellarNetworkConfig;
232
232
  /**
233
233
  * Nonce (persistent storage key) of the pool's `ZkConfig` entry this
234
- * environment's proofs/circuit shape target. Defaults to `2n` (Commitment
235
- * V2, 95 public signals) when omitted. Nonce `0` is the retired 93-signal
236
- * layout and must be passed explicitly.
234
+ * environment's proofs/circuit shape target. Defaults to `3n` (bundled 2×2
235
+ * binding layout) when omitted. Also bundled: `7n` (6×6). The value must
236
+ * match the on-chain pool config or bootstrap/execute fails with
237
+ * `no zk circuit configured for nonce …`.
237
238
  */
238
239
  zkConfigNonce?: bigint;
239
240
  /**
240
- * Optional nonce-keyed circuit map. Defaults to the SDK bundled 2×2 (nonce 2)
241
- * and 6×6 (nonce 6) schemes. URL fields are only for a custom/dev circuit.
241
+ * Optional nonce-keyed circuit map. Defaults to the SDK bundled 2×2 (nonce 3)
242
+ * and 6×6 (nonce 7) schemes. URL fields are only for a custom/dev circuit.
242
243
  */
243
244
  zkCircuits?: Record<string, StellarZkCircuitDefinition>;
244
245
  /**
@@ -363,6 +364,12 @@ interface FetchContractMerkleResult {
363
364
  merkleRootHex: string;
364
365
  updatedAt: number;
365
366
  }
367
+ /**
368
+ * Loads pool Merkle leaves without `get_commitments()`. That helper walks the
369
+ * whole tree in one simulate and exceeds the Soroban host budget on a live
370
+ * stand. Completes the cached prefix from persistent `TreeDataKey::Leaf`
371
+ * ledger entries instead.
372
+ */
366
373
  declare function fetchAndMergeMerkleState(parameters: {
367
374
  poolContractId: string;
368
375
  walletPublicKey: string;
package/dist/index.js CHANGED
@@ -810,6 +810,7 @@ function buildPoolTransactionAuditParameters(input) {
810
810
  input.nAuditSlots
811
811
  );
812
812
  }
813
+ var DECIMAL_APPLICATION_ID = /^\d+$/u;
813
814
  function resolvePoolApplicationId(applicationId) {
814
815
  const trimmed = applicationId?.trim();
815
816
  if (!trimmed) {
@@ -817,6 +818,11 @@ function resolvePoolApplicationId(applicationId) {
817
818
  "Privacy pool applicationId is required. Pass it in client factory config."
818
819
  );
819
820
  }
821
+ if (!DECIMAL_APPLICATION_ID.test(trimmed)) {
822
+ throw new Error(
823
+ "Privacy pool applicationId must be association.audit_id (decimal Fr), not a UUID or foreignId."
824
+ );
825
+ }
820
826
  return trimmed;
821
827
  }
822
828
 
@@ -1593,92 +1599,167 @@ function getPrivacyPoolService() {
1593
1599
  }
1594
1600
 
1595
1601
  // src/transact/merkle/fetch-contract.ts
1602
+ import { Buffer as Buffer12 } from "buffer";
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
+
1613
+ // src/transact/merkle/read-tree-leaves.ts
1614
+ import { Address, xdr } from "@stellar/stellar-sdk";
1596
1615
  import { Buffer as Buffer11 } from "buffer";
1597
1616
 
1598
1617
  // src/transact/merkle/encoding.ts
1599
1618
  import "buffer";
1600
1619
  var FR_ORDER = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n;
1601
- function bufferToDecimal(buf) {
1620
+ function commitmentBufferToDecimal(buf) {
1602
1621
  const hex = buf.toString("hex");
1603
1622
  const bigintFromHex = BigInt(`0x${hex}`);
1604
1623
  const reduced = bigintFromHex % FR_ORDER;
1605
1624
  return reduced.toString();
1606
1625
  }
1607
- function commitmentsBuffersToDecimal(buffers) {
1608
- return buffers.map((bufferRow) => bufferToDecimal(bufferRow));
1609
- }
1610
1626
 
1611
- // src/transact/merkle/state-port.ts
1612
- function poolMerkleStateToCachedView(state) {
1613
- return {
1614
- commitments: state.commitments,
1615
- updatedAt: state.updatedAt,
1616
- merkleRootHex: state.merkleRootHex
1617
- };
1618
- }
1619
-
1620
- // src/transact/merkle/fetch-contract.ts
1621
- function normalizeCommitmentBuffers(rawBuffers) {
1622
- return rawBuffers.map(
1623
- (bufferRow) => Buffer11.isBuffer(bufferRow) ? bufferRow : Buffer11.from(bufferRow)
1627
+ // src/transact/merkle/read-tree-leaves.ts
1628
+ var TREE_LEAF_LEDGER_BATCH_SIZE = 100;
1629
+ function treeLeafLedgerKey(contractId, leafIndex) {
1630
+ return xdr.LedgerKey.contractData(
1631
+ new xdr.LedgerKeyContractData({
1632
+ contract: new Address(contractId).toScAddress(),
1633
+ key: treeLeafKeyScValue(leafIndex),
1634
+ durability: xdr.ContractDataDurability.persistent()
1635
+ })
1624
1636
  );
1625
1637
  }
1626
- function mergeContractMerkleWithCache(parameters) {
1627
- const cachedCount = parameters.cachedState?.commitments.length ?? 0;
1628
- const shouldPreferContract = parameters.contractCount > cachedCount || !parameters.cachedState || cachedCount === 0;
1629
- if (shouldPreferContract) {
1630
- const updatedAt = Date.now();
1631
- void parameters.poolMerkleState?.set({
1632
- poolContract: parameters.poolContractId,
1633
- commitments: parameters.contractCommitments,
1634
- commitmentCount: parameters.contractCount,
1635
- merkleRootHex: parameters.merkleRootHex,
1636
- updatedAt
1637
- });
1638
- return {
1639
- commitments: parameters.contractCommitments,
1640
- updatedAt,
1641
- merkleRootHex: parameters.merkleRootHex,
1642
- commitmentCount: parameters.contractCount
1643
- };
1638
+ function treeLeafKeyScValue(leafIndex) {
1639
+ return xdr.ScVal.scvVec([xdr.ScVal.scvSymbol("Leaf"), xdr.ScVal.scvU32(leafIndex)]);
1640
+ }
1641
+ function leafIndexFromContractDataKey(key) {
1642
+ if (key.switch() !== xdr.ScValType.scvVec()) {
1643
+ return void 0;
1644
1644
  }
1645
- return {
1646
- commitments: parameters.cachedState.commitments,
1647
- updatedAt: parameters.cachedState.updatedAt,
1648
- merkleRootHex: parameters.cachedState.merkleRootHex ?? parameters.merkleRootHex,
1649
- commitmentCount: parameters.cachedState.commitments.length
1650
- };
1645
+ const fields = key.vec();
1646
+ if (!fields || fields.length !== 2) {
1647
+ return void 0;
1648
+ }
1649
+ const [tag, indexValue] = fields;
1650
+ if (!tag || tag.switch() !== xdr.ScValType.scvSymbol()) {
1651
+ return void 0;
1652
+ }
1653
+ if (tag.sym().toString() !== "Leaf") {
1654
+ return void 0;
1655
+ }
1656
+ if (!indexValue || indexValue.switch() !== xdr.ScValType.scvU32()) {
1657
+ return void 0;
1658
+ }
1659
+ return indexValue.u32();
1651
1660
  }
1652
- async function readCachedPoolMerkleView(poolMerkleState, poolContractId) {
1653
- if (!poolMerkleState) {
1661
+ function commitmentBytesFromContractDataValue(value) {
1662
+ if (value.switch() !== xdr.ScValType.scvBytes()) {
1654
1663
  return void 0;
1655
1664
  }
1656
- const cached = await poolMerkleState.get(poolContractId);
1657
- return cached ? poolMerkleStateToCachedView(cached) : void 0;
1665
+ return Buffer11.from(value.bytes());
1666
+ }
1667
+ async function readTreeLeafCommitments(input) {
1668
+ if (input.startIndex >= input.endIndex) {
1669
+ return [];
1670
+ }
1671
+ const byIndex = await readLeafBuffersByIndex(input);
1672
+ return decimalCommitmentsInRange(byIndex, input.startIndex, input.endIndex);
1673
+ }
1674
+ async function readLeafBuffersByIndex(input) {
1675
+ const keys = ledgerKeysForRange(input.contractId, input.startIndex, input.endIndex);
1676
+ const byIndex = /* @__PURE__ */ new Map();
1677
+ for (const batch of chunkLedgerKeys(keys, TREE_LEAF_LEDGER_BATCH_SIZE)) {
1678
+ const response = await input.reader.getLedgerEntries(...batch);
1679
+ collectLeafBuffers(response.entries, byIndex);
1680
+ }
1681
+ return byIndex;
1682
+ }
1683
+ function ledgerKeysForRange(contractId, startIndex, endIndex) {
1684
+ const keys = [];
1685
+ for (let leafIndex = startIndex; leafIndex < endIndex; leafIndex += 1) {
1686
+ keys.push(treeLeafLedgerKey(contractId, leafIndex));
1687
+ }
1688
+ return keys;
1689
+ }
1690
+ function chunkLedgerKeys(keys, batchSize) {
1691
+ const batches = [];
1692
+ for (let offset = 0; offset < keys.length; offset += batchSize) {
1693
+ batches.push(keys.slice(offset, offset + batchSize));
1694
+ }
1695
+ return batches;
1696
+ }
1697
+ function collectLeafBuffers(entries, byIndex) {
1698
+ for (const entry of entries) {
1699
+ const contractData = entry.val.contractData();
1700
+ const leafIndex = leafIndexFromContractDataKey(contractData.key());
1701
+ const bytes = commitmentBytesFromContractDataValue(contractData.val());
1702
+ if (leafIndex === void 0 || !bytes) {
1703
+ continue;
1704
+ }
1705
+ byIndex.set(leafIndex, bytes);
1706
+ }
1707
+ }
1708
+ function decimalCommitmentsInRange(byIndex, startIndex, endIndex) {
1709
+ const commitments = [];
1710
+ for (let leafIndex = startIndex; leafIndex < endIndex; leafIndex += 1) {
1711
+ const bytes = byIndex.get(leafIndex);
1712
+ if (!bytes) {
1713
+ throw new Error(`Missing Merkle leaf ${String(leafIndex)} in pool storage.`);
1714
+ }
1715
+ commitments.push(commitmentBufferToDecimal(bytes));
1716
+ }
1717
+ return commitments;
1718
+ }
1719
+
1720
+ // src/transact/merkle/reuse-cached-commitments.ts
1721
+ function completeCacheRootMatches(cachedState, merkleRootHex) {
1722
+ const cachedRoot = cachedState?.merkleRootHex;
1723
+ if (cachedRoot === void 0 || cachedRoot === "") {
1724
+ return true;
1725
+ }
1726
+ return cachedRoot === merkleRootHex;
1727
+ }
1728
+ function reuseCachedCommitments(input) {
1729
+ const cachedCommitments = input.cachedState?.commitments ?? [];
1730
+ if (cachedCommitments.length === 0) {
1731
+ return [];
1732
+ }
1733
+ if (cachedCommitments.length > input.onChainCount) {
1734
+ return [];
1735
+ }
1736
+ if (cachedCommitments.length === input.onChainCount) {
1737
+ return completeCacheRootMatches(input.cachedState, input.merkleRootHex) ? cachedCommitments : [];
1738
+ }
1739
+ return cachedCommitments;
1658
1740
  }
1741
+
1742
+ // src/transact/merkle/fetch-contract.ts
1659
1743
  async function fetchAndMergeMerkleState(parameters) {
1660
- const client = readPoolClientFactory(parameters.transactEnvironment)({
1661
- contractId: parameters.poolContractId,
1662
- walletPublicKey: parameters.walletPublicKey,
1663
- networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1664
- sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1665
- });
1666
- const commitmentsRead = await client.get_commitments();
1667
- const rawBuffers = commitmentsRead.result;
1668
- const buffers = normalizeCommitmentBuffers(rawBuffers);
1669
- const contractCommitments = commitmentsBuffersToDecimal(buffers);
1670
- const contractCount = contractCommitments.length;
1744
+ const client = createPoolClient(parameters);
1745
+ const countRead = await client.get_commitment_count();
1746
+ const onChainCount = requireCommitmentCount(countRead.result);
1671
1747
  const rootRead = await client.get_merkle_root();
1672
- const merkleRootBuffer = rootRead.result;
1673
- const merkleRootHex = Buffer11.from(merkleRootBuffer).toString("hex");
1748
+ const merkleRootHex = merkleRootToHex(rootRead.result);
1674
1749
  const cachedState = await readCachedPoolMerkleView(
1675
1750
  parameters.poolMerkleState,
1676
1751
  parameters.poolContractId
1677
1752
  );
1678
- return mergeContractMerkleWithCache({
1753
+ const commitments = await loadCommitments({
1754
+ cachedState,
1755
+ onChainCount,
1756
+ merkleRootHex,
1757
+ rpcUrl: parameters.transactEnvironment.network.rpcUrl,
1758
+ contractId: parameters.poolContractId
1759
+ });
1760
+ return persistFetchedMerkleState({
1679
1761
  poolContractId: parameters.poolContractId,
1680
- contractCommitments,
1681
- contractCount,
1762
+ commitments,
1682
1763
  merkleRootHex,
1683
1764
  cachedState,
1684
1765
  ...parameters.poolMerkleState ? { poolMerkleState: parameters.poolMerkleState } : {}
@@ -1692,19 +1773,14 @@ async function readLeafEphemeralHex(parameters) {
1692
1773
  if (cached?.xHex && cached.yHex) {
1693
1774
  return { xHex: cached.xHex, yHex: cached.yHex };
1694
1775
  }
1695
- const client = readPoolClientFactory(parameters.transactEnvironment)({
1696
- contractId: parameters.poolContractId,
1697
- walletPublicKey: parameters.walletPublicKey,
1698
- networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1699
- sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1700
- });
1776
+ const client = createPoolClient(parameters);
1701
1777
  const read = await client.get_leaf_ephemeral({ leaf_index: parameters.leafIndex });
1702
1778
  const coords = read.result;
1703
1779
  if (!coords?.x || !coords?.y) {
1704
1780
  throw new Error("Missing leaf ephemeral key on contract");
1705
1781
  }
1706
- const xHex = Buffer11.from(coords.x).toString("hex");
1707
- const yHex = Buffer11.from(coords.y).toString("hex");
1782
+ const xHex = Buffer12.from(coords.x).toString("hex");
1783
+ const yHex = Buffer12.from(coords.y).toString("hex");
1708
1784
  await parameters.leafEphemeral?.set({
1709
1785
  poolContract: parameters.poolContractId,
1710
1786
  leafIndex: parameters.leafIndex,
@@ -1714,6 +1790,84 @@ async function readLeafEphemeralHex(parameters) {
1714
1790
  });
1715
1791
  return { xHex, yHex };
1716
1792
  }
1793
+ function createPoolClient(parameters) {
1794
+ return readPoolClientFactory(parameters.transactEnvironment)({
1795
+ contractId: parameters.poolContractId,
1796
+ walletPublicKey: parameters.walletPublicKey,
1797
+ networkPassphrase: parameters.transactEnvironment.network.networkPassphrase,
1798
+ sorobanRpcUrl: parameters.transactEnvironment.network.rpcUrl
1799
+ });
1800
+ }
1801
+ function requireCommitmentCount(result) {
1802
+ if (typeof result === "number" && Number.isInteger(result) && result >= 0) {
1803
+ return result;
1804
+ }
1805
+ throw new Error("Pool commitment count is not a non-negative integer.");
1806
+ }
1807
+ function merkleRootToHex(root) {
1808
+ return Buffer12.from(root).toString("hex");
1809
+ }
1810
+ async function readCachedPoolMerkleView(poolMerkleState, poolContractId) {
1811
+ if (!poolMerkleState) {
1812
+ return void 0;
1813
+ }
1814
+ const cached = await poolMerkleState.get(poolContractId);
1815
+ return cached ? poolMerkleStateToCachedView(cached) : void 0;
1816
+ }
1817
+ async function loadCommitments(input) {
1818
+ const reused = reuseCachedCommitments({
1819
+ cachedState: input.cachedState,
1820
+ onChainCount: input.onChainCount,
1821
+ merkleRootHex: input.merkleRootHex
1822
+ });
1823
+ if (reused.length === input.onChainCount) {
1824
+ return reused;
1825
+ }
1826
+ const fetched = await readTreeLeafCommitments({
1827
+ reader: createStellarRpcServer(input.rpcUrl),
1828
+ contractId: input.contractId,
1829
+ startIndex: reused.length,
1830
+ endIndex: input.onChainCount
1831
+ });
1832
+ return [...reused, ...fetched];
1833
+ }
1834
+ async function persistFetchedMerkleState(input) {
1835
+ const cachedState = input.cachedState;
1836
+ if (cachedState && cachedMerkleUnchanged(cachedState, input.commitments, input.merkleRootHex)) {
1837
+ return viewFromCachedMerkle(cachedState, input.merkleRootHex);
1838
+ }
1839
+ const updatedAt = Date.now();
1840
+ await input.poolMerkleState?.set({
1841
+ poolContract: input.poolContractId,
1842
+ commitments: input.commitments,
1843
+ commitmentCount: input.commitments.length,
1844
+ merkleRootHex: input.merkleRootHex,
1845
+ updatedAt
1846
+ });
1847
+ return {
1848
+ commitments: input.commitments,
1849
+ updatedAt,
1850
+ merkleRootHex: input.merkleRootHex,
1851
+ commitmentCount: input.commitments.length
1852
+ };
1853
+ }
1854
+ function viewFromCachedMerkle(cachedState, merkleRootHex) {
1855
+ return {
1856
+ commitments: cachedState.commitments,
1857
+ updatedAt: cachedState.updatedAt,
1858
+ merkleRootHex: cachedState.merkleRootHex ?? merkleRootHex,
1859
+ commitmentCount: cachedState.commitments.length
1860
+ };
1861
+ }
1862
+ function cachedMerkleUnchanged(cachedState, commitments, merkleRootHex) {
1863
+ if (!cachedState) {
1864
+ return false;
1865
+ }
1866
+ if ((cachedState.merkleRootHex ?? merkleRootHex) !== merkleRootHex) {
1867
+ return false;
1868
+ }
1869
+ return cachedState.commitments.join(",") === commitments.join(",");
1870
+ }
1717
1871
 
1718
1872
  // src/transact/engine/prepare/shared.ts
1719
1873
  async function resolveTokenContractId2(environment, assetId) {
@@ -4257,7 +4411,7 @@ function createStellarStorageAdapterFromState(state) {
4257
4411
  }
4258
4412
 
4259
4413
  // src/contracts/registry/registry-domain-service.ts
4260
- import { Buffer as Buffer12 } from "buffer";
4414
+ import { Buffer as Buffer13 } from "buffer";
4261
4415
 
4262
4416
  // src/transact/submit/ttl-preflight.ts
4263
4417
  function getNested(source, path) {
@@ -4306,11 +4460,11 @@ async function runTtlPreflight(assembledTransaction) {
4306
4460
  // src/contracts/registry/registry-domain-service.ts
4307
4461
  var COORDINATE_HEX_LENGTH = 64;
4308
4462
  function readCoordinateBytes(value) {
4309
- if (value instanceof Buffer12) {
4463
+ if (value instanceof Buffer13) {
4310
4464
  return value;
4311
4465
  }
4312
4466
  if (value instanceof Uint8Array) {
4313
- return Buffer12.from(value);
4467
+ return Buffer13.from(value);
4314
4468
  }
4315
4469
  return void 0;
4316
4470
  }
@@ -4349,8 +4503,8 @@ function parseRegistryLookupRecord(result) {
4349
4503
  return parseOptionSomeRecord(result);
4350
4504
  }
4351
4505
  function recordToLookupResult(record) {
4352
- const publicKeyXHex = Buffer12.from(record.public_key_x).toString("hex");
4353
- const publicKeyYHex = Buffer12.from(record.public_key_y).toString("hex");
4506
+ const publicKeyXHex = Buffer13.from(record.public_key_x).toString("hex");
4507
+ const publicKeyYHex = Buffer13.from(record.public_key_y).toString("hex");
4354
4508
  return {
4355
4509
  owner: record.owner,
4356
4510
  status: "registered",
@@ -4393,8 +4547,8 @@ async function registerPrivateAddressOnChain(input) {
4393
4547
  });
4394
4548
  const assembled = await client.register_private_address({
4395
4549
  owner: input.owner.trim(),
4396
- public_key_x: Buffer12.from(decoded.x.padStart(COORDINATE_HEX_LENGTH, "0"), "hex"),
4397
- public_key_y: Buffer12.from(decoded.y.padStart(COORDINATE_HEX_LENGTH, "0"), "hex")
4550
+ public_key_x: Buffer13.from(decoded.x.padStart(COORDINATE_HEX_LENGTH, "0"), "hex"),
4551
+ public_key_y: Buffer13.from(decoded.y.padStart(COORDINATE_HEX_LENGTH, "0"), "hex")
4398
4552
  });
4399
4553
  await runTtlPreflight(assembled);
4400
4554
  const sent = await assembled.signAndSend();
@@ -4409,7 +4563,7 @@ async function registerPrivateAddressOnChain(input) {
4409
4563
  import { StrKey as StrKey5 } from "@stellar/stellar-sdk";
4410
4564
 
4411
4565
  // src/transact/escrow/derived-escrow-recipient.ts
4412
- import { Buffer as Buffer13 } from "buffer";
4566
+ import { Buffer as Buffer14 } from "buffer";
4413
4567
  import { StrKey as StrKey4 } from "@stellar/stellar-sdk";
4414
4568
  import {
4415
4569
  derivedEscrowKey,
@@ -4419,7 +4573,7 @@ import {
4419
4573
  var COORDINATE_HEX_LENGTH2 = 64;
4420
4574
  function stellarAccountToFieldLimbs(stellarAddress) {
4421
4575
  const pkRaw = StrKey4.decodeEd25519PublicKey(stellarAddress.trim());
4422
- const pkHex = Buffer13.from(pkRaw).toString("hex");
4576
+ const pkHex = Buffer14.from(pkRaw).toString("hex");
4423
4577
  const { hi, lo } = ed25519PubkeyPayloadHexToWithdrawFrDecimals2(pkHex);
4424
4578
  return { recipientHi: hi, recipientLo: lo };
4425
4579
  }
@@ -4504,7 +4658,7 @@ async function resolveTransferRecipientFromChain(input) {
4504
4658
  import { Api } from "@stellar/stellar-sdk/rpc";
4505
4659
 
4506
4660
  // src/rpc/soroban-transaction-meta.ts
4507
- import { Address, StrKey as StrKey6 } from "@stellar/stellar-sdk";
4661
+ import { Address as Address2, StrKey as StrKey6 } from "@stellar/stellar-sdk";
4508
4662
  var BIGINT_SHIFT_64 = 64n;
4509
4663
  var TRANSACTION_META_SWITCH_SOROBAN_V3 = 3;
4510
4664
  var TRANSACTION_META_SWITCH_SOROBAN_V4 = 4;
@@ -4604,8 +4758,8 @@ function transferPartyAddressesFromTopics(topics) {
4604
4758
  return void 0;
4605
4759
  }
4606
4760
  return {
4607
- from: Address.fromScVal(fromTopic).toString(),
4608
- to: Address.fromScVal(toTopic).toString()
4761
+ from: Address2.fromScVal(fromTopic).toString(),
4762
+ to: Address2.fromScVal(toTopic).toString()
4609
4763
  };
4610
4764
  } catch {
4611
4765
  return void 0;
@@ -6376,20 +6530,20 @@ async function waitForKytRegistration(parameters) {
6376
6530
  }
6377
6531
 
6378
6532
  // src/transact/kyt/passage/submit.ts
6379
- import { Buffer as Buffer14 } from "buffer";
6380
- import { Operation, TransactionBuilder, rpc as rpc3, xdr as xdr2 } from "@stellar/stellar-sdk";
6533
+ import { Buffer as Buffer15 } from "buffer";
6534
+ import { Operation, TransactionBuilder, rpc as rpc3, xdr as xdr3 } from "@stellar/stellar-sdk";
6381
6535
  var KYT_REGISTER_FEE_STROOPS = "1000000";
6382
6536
  var KYT_REGISTER_TIMEOUT_SECONDS = 300;
6383
6537
  function passageIdToScValue(passageId) {
6384
- return xdr2.ScVal.scvBytes(Buffer14.from(passageId.replace(/^0x/, ""), "hex"));
6538
+ return xdr3.ScVal.scvBytes(Buffer15.from(passageId.replace(/^0x/, ""), "hex"));
6385
6539
  }
6386
6540
  function approvalSignatureToBytes(signature) {
6387
6541
  const clean = signature.trim();
6388
- return /^(0x)?[0-9a-fA-F]{128}$/.test(clean) ? Buffer14.from(clean.replace(/^0x/i, ""), "hex") : Buffer14.from(clean, "base64");
6542
+ return /^(0x)?[0-9a-fA-F]{128}$/.test(clean) ? Buffer15.from(clean.replace(/^0x/i, ""), "hex") : Buffer15.from(clean, "base64");
6389
6543
  }
6390
6544
  function signatureToScValue(signature) {
6391
6545
  const bytes = approvalSignatureToBytes(signature);
6392
- return xdr2.ScVal.scvBytes(bytes);
6546
+ return xdr3.ScVal.scvBytes(bytes);
6393
6547
  }
6394
6548
  async function registerKytPassage(parameters) {
6395
6549
  const signTransaction = parameters.transactEnvironment.signTransaction;
@@ -6410,7 +6564,7 @@ async function registerKytPassage(parameters) {
6410
6564
  function: "register_passage",
6411
6565
  args: [
6412
6566
  passageIdToScValue(parameters.approval.passageId),
6413
- xdr2.ScVal.scvU32(parameters.approval.expiresAtLedger),
6567
+ xdr3.ScVal.scvU32(parameters.approval.expiresAtLedger),
6414
6568
  signatureToScValue(parameters.approval.signature)
6415
6569
  ]
6416
6570
  })
@@ -6535,12 +6689,12 @@ async function requestKytPassageForPoolInteraction(input) {
6535
6689
 
6536
6690
  // src/transact/submit/zk-config-ttl.ts
6537
6691
  import {
6538
- Address as Address2,
6692
+ Address as Address3,
6539
6693
  Operation as Operation2,
6540
6694
  SorobanDataBuilder,
6541
6695
  TransactionBuilder as TransactionBuilder2,
6542
6696
  rpc as rpc4,
6543
- xdr as xdr3
6697
+ xdr as xdr4
6544
6698
  } from "@stellar/stellar-sdk";
6545
6699
  var ZK_CONFIG_TTL_THRESHOLD_LEDGERS = 1e5;
6546
6700
  var ZK_CONFIG_TTL_EXTEND_TO_LEDGERS = 5e5;
@@ -6564,15 +6718,15 @@ async function waitForExtendFootprintTtlConfirmation(parameters) {
6564
6718
  throw new Error("ZK config TTL extension was not confirmed in time");
6565
6719
  }
6566
6720
  function zkConfigLedgerKey(contractId, nonce) {
6567
- const configKeyScValue = xdr3.ScVal.scvVec([
6568
- xdr3.ScVal.scvSymbol("Config"),
6569
- xdr3.ScVal.scvU64(xdr3.Uint64.fromString(nonce.toString()))
6721
+ const configKeyScValue = xdr4.ScVal.scvVec([
6722
+ xdr4.ScVal.scvSymbol("Config"),
6723
+ xdr4.ScVal.scvU64(xdr4.Uint64.fromString(nonce.toString()))
6570
6724
  ]);
6571
- return xdr3.LedgerKey.contractData(
6572
- new xdr3.LedgerKeyContractData({
6573
- contract: new Address2(contractId).toScAddress(),
6725
+ return xdr4.LedgerKey.contractData(
6726
+ new xdr4.LedgerKeyContractData({
6727
+ contract: new Address3(contractId).toScAddress(),
6574
6728
  key: configKeyScValue,
6575
- durability: xdr3.ContractDataDurability.persistent()
6729
+ durability: xdr4.ContractDataDurability.persistent()
6576
6730
  })
6577
6731
  );
6578
6732
  }
@@ -6637,7 +6791,7 @@ async function extendZkConfigTtlIfNeeded(parameters) {
6637
6791
  }
6638
6792
 
6639
6793
  // src/transact/submit/pool-transact.ts
6640
- import { Buffer as Buffer15 } from "buffer";
6794
+ import { Buffer as Buffer16 } from "buffer";
6641
6795
  async function submitPoolTransact(parameters) {
6642
6796
  await extendZkConfigTtlIfNeeded({
6643
6797
  sorobanRpcUrl: parameters.sorobanRpcUrl,
@@ -6650,9 +6804,9 @@ async function submitPoolTransact(parameters) {
6650
6804
  const assembledTransaction = await parameters.contractClient.transact({
6651
6805
  from: parameters.from,
6652
6806
  nonce: parameters.nonce,
6653
- proof_bytes: Buffer15.from(parameters.proofHex.replace(/^0x/iu, ""), "hex"),
6654
- pub_signals_bytes: Buffer15.from(parameters.publicHex.replace(/^0x/iu, ""), "hex"),
6655
- ciphertext_bytes: Buffer15.from(
6807
+ proof_bytes: Buffer16.from(parameters.proofHex.replace(/^0x/iu, ""), "hex"),
6808
+ pub_signals_bytes: Buffer16.from(parameters.publicHex.replace(/^0x/iu, ""), "hex"),
6809
+ ciphertext_bytes: Buffer16.from(
6656
6810
  (parameters.ciphertextHex ?? "").replace(/^0x/iu, ""),
6657
6811
  "hex"
6658
6812
  ),
@@ -7217,13 +7371,13 @@ async function fetchEscrowOutputNoteEvents(input) {
7217
7371
  // src/transact/escrow/simulate-escrow-authorization.ts
7218
7372
  import {
7219
7373
  Account,
7220
- Address as Address4,
7374
+ Address as Address5,
7221
7375
  Contract,
7222
7376
  nativeToScVal as nativeToScVal2,
7223
7377
  TransactionBuilder as TransactionBuilder3,
7224
7378
  rpc as rpc5
7225
7379
  } from "@stellar/stellar-sdk";
7226
- import { Buffer as Buffer16 } from "buffer";
7380
+ import { Buffer as Buffer17 } from "buffer";
7227
7381
 
7228
7382
  // src/transact/escrow/kyt-authorization-sc-value.ts
7229
7383
  import { nativeToScVal } from "@stellar/stellar-sdk";
@@ -7243,14 +7397,14 @@ function kytAuthorizationScValue(parameters) {
7243
7397
  }
7244
7398
 
7245
7399
  // src/transact/escrow/pick-escrow-authorization.ts
7246
- import { Address as Address3 } from "@stellar/stellar-sdk";
7400
+ import { Address as Address4 } from "@stellar/stellar-sdk";
7247
7401
  function credentialAddress(entry) {
7248
7402
  try {
7249
7403
  const credentials = entry.credentials();
7250
7404
  if (credentials.switch().name !== "sorobanCredentialsAddress") {
7251
7405
  return void 0;
7252
7406
  }
7253
- return Address3.fromScAddress(credentials.address().address()).toString();
7407
+ return Address4.fromScAddress(credentials.address().address()).toString();
7254
7408
  } catch {
7255
7409
  return void 0;
7256
7410
  }
@@ -7269,7 +7423,7 @@ var SIMULATE_FEE = "100";
7269
7423
  var SIMULATE_TIMEOUT_SECONDS = 30;
7270
7424
  var RECORD_NONROOT_AUTH = "record_allow_nonroot";
7271
7425
  function hexToBytes(hex) {
7272
- return Buffer16.from(hex.replace(/^0x/iu, ""), "hex");
7426
+ return Buffer17.from(hex.replace(/^0x/iu, ""), "hex");
7273
7427
  }
7274
7428
  function optionalSweepCiphertext(artifacts) {
7275
7429
  return {
@@ -7322,7 +7476,7 @@ async function simulateSweepAuthEntries(input) {
7322
7476
  const account = await server.getAccount(input.relayerPublicKey);
7323
7477
  const operation = new Contract(environment.network.poolContract).call(
7324
7478
  "transact",
7325
- new Address4(input.relayerPublicKey).toScVal(),
7479
+ new Address5(input.relayerPublicKey).toScVal(),
7326
7480
  nativeToScVal2(resolveZkConfigNonce(environment), { type: "u64" }),
7327
7481
  nativeToScVal2(hexToBytes(input.artifacts.proofHex), { type: "bytes" }),
7328
7482
  nativeToScVal2(hexToBytes(input.artifacts.publicHex), { type: "bytes" }),
@@ -7493,7 +7647,7 @@ var RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT = 91;
7493
7647
  var RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL = 92;
7494
7648
 
7495
7649
  // src/transact/relay/signals.ts
7496
- import { Buffer as Buffer17 } from "buffer";
7650
+ import { Buffer as Buffer18 } from "buffer";
7497
7651
 
7498
7652
  // src/transact/relay/layout-profile.ts
7499
7653
  var FIELD_BYTES = 32;
@@ -7573,7 +7727,7 @@ function relayLayoutProfileForNonce(nonce) {
7573
7727
 
7574
7728
  // src/transact/relay/signals.ts
7575
7729
  function decodePublicSignalBytes(publicSignals) {
7576
- return Buffer17.from(publicSignals.replace(/^0x/iu, ""), "hex");
7730
+ return Buffer18.from(publicSignals.replace(/^0x/iu, ""), "hex");
7577
7731
  }
7578
7732
  function hasSupportedLengthPrefix(bytes, signalCount) {
7579
7733
  const expected = RELAY_TRANSACT_SIGNAL_PREFIX_BYTES + signalCount * RELAY_TRANSACT_FIELD_BYTES;
@@ -7600,7 +7754,7 @@ function sliceSupportedPublicSignalFields(publicSignals, zkConfigNonce = DEFAULT
7600
7754
  const body = hasSupportedLengthPrefix(bytes, profile.signalCount) ? bytes.subarray(RELAY_TRANSACT_SIGNAL_PREFIX_BYTES) : bytes;
7601
7755
  return Array.from(
7602
7756
  { length: profile.signalCount },
7603
- (_unused, index) => Buffer17.from(
7757
+ (_unused, index) => Buffer18.from(
7604
7758
  body.subarray(
7605
7759
  index * RELAY_TRANSACT_FIELD_BYTES,
7606
7760
  (index + 1) * RELAY_TRANSACT_FIELD_BYTES