@interest-protocol/vortex-sdk 8.0.0 → 8.1.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 +31 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/decrypt.d.ts +4 -0
- package/dist/utils/decrypt.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/utils/decrypt.ts +52 -0
package/dist/index.js
CHANGED
|
@@ -38782,6 +38782,36 @@ 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(commitment);
|
|
38796
|
+
allUtxos.push(utxo);
|
|
38797
|
+
}
|
|
38798
|
+
catch {
|
|
38799
|
+
// Do nothing
|
|
38800
|
+
}
|
|
38801
|
+
});
|
|
38802
|
+
const utxos = allUtxos.map((utxo) => new Utxo({
|
|
38803
|
+
...utxo,
|
|
38804
|
+
keypair: vortexKeypair,
|
|
38805
|
+
vortexPool: vortexObject.objectId,
|
|
38806
|
+
}));
|
|
38807
|
+
const nullifiers = utxos.map((utxo) => utxo.nullifier());
|
|
38808
|
+
const isNullifierSpentArray = await vortexSdk.areNullifiersSpent({
|
|
38809
|
+
nullifiers,
|
|
38810
|
+
vortexPool,
|
|
38811
|
+
});
|
|
38812
|
+
const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
|
|
38813
|
+
return { unspentUtxos, userCommitments };
|
|
38814
|
+
};
|
|
38785
38815
|
|
|
38786
38816
|
const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS = [
|
|
38787
38817
|
{
|
|
@@ -39857,6 +39887,7 @@ exports.finishSwap = finishSwap;
|
|
|
39857
39887
|
exports.getMerklePath = getMerklePath;
|
|
39858
39888
|
exports.getUnspentUtxos = getUnspentUtxos;
|
|
39859
39889
|
exports.getUnspentUtxosWithApi = getUnspentUtxosWithApi;
|
|
39890
|
+
exports.getUnspentUtxosWithApiAndCommitments = getUnspentUtxosWithApiAndCommitments;
|
|
39860
39891
|
exports.merkleTreeHashFunction = merkleTreeHashFunction;
|
|
39861
39892
|
exports.parseNewCommitmentEvent = parseNewCommitmentEvent;
|
|
39862
39893
|
exports.parseVortexPool = parseVortexPool;
|