@interest-protocol/vortex-sdk 8.0.0 → 8.2.0

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.js CHANGED
@@ -38782,6 +38782,39 @@ const getUnspentUtxosWithApi = async ({ commitments, vortexKeypair, vortexSdk, v
38782
38782
  const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
38783
38783
  return unspentUtxos;
38784
38784
  };
38785
+ const getUnspentUtxosWithApiAndCommitments = async ({ commitments, vortexKeypair, vortexSdk, vortexPool, }) => {
38786
+ const allUtxos = [];
38787
+ const userCommitments = [];
38788
+ const vortexObject = await vortexSdk.resolveVortexPool(vortexPool);
38789
+ commitments.forEach((commitment) => {
38790
+ invariant(normalizeStructTag(commitment.coinType) ===
38791
+ normalizeStructTag(vortexObject.coinType), 'Commitment coin type does not match vortex pool coin type');
38792
+ try {
38793
+ const encryptedOutputHex = toHex(Uint8Array.from(commitment.encryptedOutput));
38794
+ const utxo = vortexKeypair.decryptUtxo(encryptedOutputHex);
38795
+ userCommitments.push({
38796
+ coinType: commitment.coinType,
38797
+ encryptedOutput: commitment.encryptedOutput,
38798
+ });
38799
+ allUtxos.push(utxo);
38800
+ }
38801
+ catch {
38802
+ // Do nothing
38803
+ }
38804
+ });
38805
+ const utxos = allUtxos.map((utxo) => new Utxo({
38806
+ ...utxo,
38807
+ keypair: vortexKeypair,
38808
+ vortexPool: vortexObject.objectId,
38809
+ }));
38810
+ const nullifiers = utxos.map((utxo) => utxo.nullifier());
38811
+ const isNullifierSpentArray = await vortexSdk.areNullifiersSpent({
38812
+ nullifiers,
38813
+ vortexPool,
38814
+ });
38815
+ const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
38816
+ return { unspentUtxos, userCommitments };
38817
+ };
38785
38818
 
38786
38819
  const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS = [
38787
38820
  {
@@ -39857,6 +39890,7 @@ exports.finishSwap = finishSwap;
39857
39890
  exports.getMerklePath = getMerklePath;
39858
39891
  exports.getUnspentUtxos = getUnspentUtxos;
39859
39892
  exports.getUnspentUtxosWithApi = getUnspentUtxosWithApi;
39893
+ exports.getUnspentUtxosWithApiAndCommitments = getUnspentUtxosWithApiAndCommitments;
39860
39894
  exports.merkleTreeHashFunction = merkleTreeHashFunction;
39861
39895
  exports.parseNewCommitmentEvent = parseNewCommitmentEvent;
39862
39896
  exports.parseVortexPool = parseVortexPool;