@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.mjs CHANGED
@@ -38780,6 +38780,39 @@ const getUnspentUtxosWithApi = async ({ commitments, vortexKeypair, vortexSdk, v
38780
38780
  const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
38781
38781
  return unspentUtxos;
38782
38782
  };
38783
+ const getUnspentUtxosWithApiAndCommitments = async ({ commitments, vortexKeypair, vortexSdk, vortexPool, }) => {
38784
+ const allUtxos = [];
38785
+ const userCommitments = [];
38786
+ const vortexObject = await vortexSdk.resolveVortexPool(vortexPool);
38787
+ commitments.forEach((commitment) => {
38788
+ invariant(normalizeStructTag(commitment.coinType) ===
38789
+ normalizeStructTag(vortexObject.coinType), 'Commitment coin type does not match vortex pool coin type');
38790
+ try {
38791
+ const encryptedOutputHex = toHex(Uint8Array.from(commitment.encryptedOutput));
38792
+ const utxo = vortexKeypair.decryptUtxo(encryptedOutputHex);
38793
+ userCommitments.push({
38794
+ coinType: commitment.coinType,
38795
+ encryptedOutput: commitment.encryptedOutput,
38796
+ });
38797
+ allUtxos.push(utxo);
38798
+ }
38799
+ catch {
38800
+ // Do nothing
38801
+ }
38802
+ });
38803
+ const utxos = allUtxos.map((utxo) => new Utxo({
38804
+ ...utxo,
38805
+ keypair: vortexKeypair,
38806
+ vortexPool: vortexObject.objectId,
38807
+ }));
38808
+ const nullifiers = utxos.map((utxo) => utxo.nullifier());
38809
+ const isNullifierSpentArray = await vortexSdk.areNullifiersSpent({
38810
+ nullifiers,
38811
+ vortexPool,
38812
+ });
38813
+ const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
38814
+ return { unspentUtxos, userCommitments };
38815
+ };
38783
38816
 
38784
38817
  const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS = [
38785
38818
  {
@@ -39821,5 +39854,5 @@ const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPoo
39821
39854
  });
39822
39855
  };
39823
39856
 
39824
- export { Action, BASIS_POINTS, BN254_FIELD_MODULUS, DEPOSIT_FEE_IN_BASIS_POINTS, EMPTY_COMMITMENT, EMPTY_SUBTREE_HASHES, ERROR_CODES, INITIAL_SHARED_VERSION, LSK_ENCRYPTED_OUTPUTS, LSK_FETCH_OFFSET, MERKLE_TREE_HEIGHT, Modules, OPT, REGISTRY_OBJECT_ID, ROOT_HISTORY_SIZE, TREASURY_ADDRESS, Utxo, VORTEX_API_URL, VORTEX_PACKAGE_ID, VORTEX_POOL_IDS, VORTEX_SIGNATURE_DOMAIN, VORTEX_SWAP_PACKAGE_ID, VORTEX_SWAP_UPGRADE_CAP, VORTEX_UPGRADE_CAP, Vortex, VortexAPI, VortexKeypair, ZERO_VALUE, buildMerkleTree, deposit, depositWithAccount, deserializeMerkleTree, finishSwap, getMerklePath, getUnspentUtxos, getUnspentUtxosWithApi, merkleTreeHashFunction, parseNewCommitmentEvent, parseVortexPool, poseidon1, poseidon2, poseidon3, poseidon4, startSwap, toProveInput, validateDepositWithAccountCommands, validateWithdrawCommands, vortexAPI, withdraw, withdrawWithAccount };
39857
+ export { Action, BASIS_POINTS, BN254_FIELD_MODULUS, DEPOSIT_FEE_IN_BASIS_POINTS, EMPTY_COMMITMENT, EMPTY_SUBTREE_HASHES, ERROR_CODES, INITIAL_SHARED_VERSION, LSK_ENCRYPTED_OUTPUTS, LSK_FETCH_OFFSET, MERKLE_TREE_HEIGHT, Modules, OPT, REGISTRY_OBJECT_ID, ROOT_HISTORY_SIZE, TREASURY_ADDRESS, Utxo, VORTEX_API_URL, VORTEX_PACKAGE_ID, VORTEX_POOL_IDS, VORTEX_SIGNATURE_DOMAIN, VORTEX_SWAP_PACKAGE_ID, VORTEX_SWAP_UPGRADE_CAP, VORTEX_UPGRADE_CAP, Vortex, VortexAPI, VortexKeypair, ZERO_VALUE, buildMerkleTree, deposit, depositWithAccount, deserializeMerkleTree, finishSwap, getMerklePath, getUnspentUtxos, getUnspentUtxosWithApi, getUnspentUtxosWithApiAndCommitments, merkleTreeHashFunction, parseNewCommitmentEvent, parseVortexPool, poseidon1, poseidon2, poseidon3, poseidon4, startSwap, toProveInput, validateDepositWithAccountCommands, validateWithdrawCommands, vortexAPI, withdraw, withdrawWithAccount };
39825
39858
  //# sourceMappingURL=index.mjs.map