Skip to content

Commit

Permalink
Merge pull request #131 from VerusCoin/multicurrency
Browse files Browse the repository at this point in the history
Fix bug with non-convertable paths in conversion suggestion list, and…
  • Loading branch information
Asherda authored Jul 3, 2023
2 parents c68b1b0 + 9bf4bd7 commit c77b3ab
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "eslint ."
},
"dependencies": {
"@bitgo/utxo-lib": "git+https://github.com/VerusCoin/BitGoJS.git#b67425ce865ac0032412a1e74c2b1fce3aaf017f",
"@bitgo/utxo-lib": "git+https://github.com/VerusCoin/BitGoJS.git#50702ca84a848020af601081904e6db75c978b78",
"@ethersproject/signing-key": "5.0.5",
"@react-native-async-storage/async-storage": "1.17.10",
"@react-native-camera-roll/camera-roll": "5.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@ export const getCurrencyConversionPaths = async (systemId, src, dest) => {
destDefinition = destResponse.result
}

return endpoint.getCurrencyConversionPaths(sourceDefinition, destDefinition);
const paths = await endpoint.getCurrencyConversionPaths(sourceDefinition, destDefinition);

for (const destinationid in paths) {
paths[destinationid] = paths[destinationid].filter(x => {
const offSystem = (x.destination.systemid != systemId) || (x.via != null && x.via.systemid != systemId)

return !(offSystem && x.exportto == null)
});
}

return paths;
}
8 changes: 6 additions & 2 deletions src/utils/api/channels/vrpc/requests/preflight.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser,
await saveFriendlyName(coinObj.system_id)
}

if (!friendlyNames.has(systemId)) {
await saveFriendlyName(systemId)
}

const {
currency,
convertto,
Expand Down Expand Up @@ -293,7 +297,7 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser,

if (isNativeSend && (txSatsBn.plus(nativeFeesPaid)).isGreaterThan(balanceBn)) {
output.satoshis = txSatsBn.minus(nativeFeesPaid).toString();
const newTxSatsBn = BigNumber(output.satoshis)
const newTxSatsBn = BigNumber(output.satoshis);

if ((newTxSatsBn.plus(nativeFeesPaid)).isGreaterThan(balanceBn)) {
throw new Error("Insufficient funds.")
Expand Down Expand Up @@ -324,7 +328,7 @@ export const preflightCurrencyTransfer = async (coinObj, channelId, activeUser,
const sendCurrencyRes = await getSendCurrencyTransaction(
systemId,
currency,
satsToCoins(txSatsBn).toNumber(),
satsToCoins(BigNumber(output.satoshis)).toNumber(),
addrDest,
exportto,
convertto,
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,9 @@
"@bitgo/blake2b-wasm" "^3.0.1"
nanoassert "^2.0.0"

"@bitgo/utxo-lib@git+https://github.com/VerusCoin/BitGoJS.git#b67425ce865ac0032412a1e74c2b1fce3aaf017f":
"@bitgo/utxo-lib@git+https://github.com/VerusCoin/BitGoJS.git#50702ca84a848020af601081904e6db75c978b78":
version "1.9.6"
resolved "git+https://github.com/VerusCoin/BitGoJS.git#b67425ce865ac0032412a1e74c2b1fce3aaf017f"
resolved "git+https://github.com/VerusCoin/BitGoJS.git#50702ca84a848020af601081904e6db75c978b78"
dependencies:
"@bitgo/blake2b" "3.0.1"
bech32 "0.0.3"
Expand Down

0 comments on commit c77b3ab

Please sign in to comment.