@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.mjs
CHANGED
|
@@ -38780,6 +38780,36 @@ 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(commitment);
|
|
38794
|
+
allUtxos.push(utxo);
|
|
38795
|
+
}
|
|
38796
|
+
catch {
|
|
38797
|
+
// Do nothing
|
|
38798
|
+
}
|
|
38799
|
+
});
|
|
38800
|
+
const utxos = allUtxos.map((utxo) => new Utxo({
|
|
38801
|
+
...utxo,
|
|
38802
|
+
keypair: vortexKeypair,
|
|
38803
|
+
vortexPool: vortexObject.objectId,
|
|
38804
|
+
}));
|
|
38805
|
+
const nullifiers = utxos.map((utxo) => utxo.nullifier());
|
|
38806
|
+
const isNullifierSpentArray = await vortexSdk.areNullifiersSpent({
|
|
38807
|
+
nullifiers,
|
|
38808
|
+
vortexPool,
|
|
38809
|
+
});
|
|
38810
|
+
const unspentUtxos = utxos.filter((_, index) => !isNullifierSpentArray[index]);
|
|
38811
|
+
return { unspentUtxos, userCommitments };
|
|
38812
|
+
};
|
|
38783
38813
|
|
|
38784
38814
|
const EXPECTED_DEPOSIT_WITH_ACCOUNT_COMMANDS = [
|
|
38785
38815
|
{
|
|
@@ -39821,5 +39851,5 @@ const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPoo
|
|
|
39821
39851
|
});
|
|
39822
39852
|
};
|
|
39823
39853
|
|
|
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 };
|
|
39854
|
+
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
39855
|
//# sourceMappingURL=index.mjs.map
|